Create an Account
username: password:
 
  MemeStreams Logo

MemeStreams Discussion

search


This page contains all of the posts and discussion on MemeStreams referencing the following web page: IO::All - IO::All of it to Graham and Damian! - search.cpan.org. You can find discussions on MemeStreams as you surf the web, even if you aren't a MemeStreams member, using the Threads Bookmarklet.

IO::All - IO::All of it to Graham and Damian! - search.cpan.org
by Lost at 1:03 pm EDT, May 6, 2008

use IO::All;

# Let the madness begin...
# Some of the many ways to read a whole file into a scalar
io('file.txt') > $contents;

# Overloaded "arrow"
$contents < io 'file.txt';

# Flipped but same operation
$io = io 'file.txt';

# Create a new IO::All object
$contents = $$io;

# Overloaded scalar dereference $contents =
$io->all;

# A method to read everything
$contents = $io->slurp;

# Another method for that
$contents = join '', $io->getlines;

# Join the separate lines
$contents = join '', map "$_\n", @$io;

# Same. Overloaded array deref
$io->tie;

# Tie the object as a handle
$contents = join '', <$io>;

# And use it in builtins # and the list goes on ...

Super neat lib.


 
 
Powered By Industrial Memetics