Create an Account
username: password:
 
  MemeStreams Logo

IO::All - IO::All of it to Graham and Damian! - search.cpan.org

search

Lost
Picture of Lost
My Blog
My Profile
My Audience
My Sources
Send Me a Message

sponsored links

Lost's topics
Arts
Business
Games
Health and Wellness
Home and Garden
Miscellaneous
Current Events
Recreation
Local Information
Science
Society
Sports
Technology

support us

Get MemeStreams Stuff!


 
IO::All - IO::All of it to Graham and Damian! - search.cpan.org
Topic: Miscellaneous 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.

IO::All - IO::All of it to Graham and Damian! - search.cpan.org



 
 
Powered By Industrial Memetics
RSS2.0