If you really need to, you can open a descriptor file for it.
use strict; use warnings; my $lines = "one\ntwo\nthree"; open my $fh, "<", \$lines; while( <$fh> ) { print "line $.: $_"; }
Alternatively, if you already have the material in memory, you can simply split it into an array:
my @lines = split /\n/, $lines;
It will probably be easier to read and maintain the line.
friedo
source share