in reply to Reading a variable as a file

use 5.008000; # open \$var open(my $fh, '<', \$var); while (<$fh>) { ... }

or

while ($var =~ /(.*\n|.+)/g) { ... }

Replies are listed 'Best First'.
Re^2: Reading a variable as a file
by codeacrobat (Chaplain) on Nov 23, 2007 at 20:14 UTC
    Cool. I didn't know it also works with refs. An alternative is IO::Scalar.
    use IO::Scalar; ### Open a handle on a string, read it line-by-line, then close it: $SH = new IO::Scalar \$var; while (<$SH>) { # ... } close $SH;

    print+qq(\L@{[ref\&@]}@{['@'x7^'!#2/"!4']});