Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

cloudnine (5985)

cloudnine
  (email not shown publicly)

Journal of cloudnine (5985)

Thursday July 06, 2006
11:45 PM

treating a string like a file

[ #30196 ]
Seems there's always something new to learn. Old, but interesting news I just found out. Pre perl 5.8, one would use IO::String to treat a string like a file. With perl 5.8, one can do this using native open:

my $string = "Foo\nBar\nBaz";
open(my $fh, '<', \$string) or die "DOH: $!";

my $line1 = <$fh>;
my $line2 = <$fh>;

## $/ is of course obeyed ....

Next thing you know, there will be a musical genre named grunge ....
The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.