Jean-Rene David wrote:
Hi,

Hello,

I wonder what idioms are available to loop through
the lines stored in a scalar variable. I guess I'm
looking for something analogous to these idioms
for files and arrays respectively:

while(<FH>) {
# do stuff
}

open FH, '<', \$scalar or die "Cannot open \$scalar $!";

while ( <FH> ) {
    # do stuff
    }


foreach (@array) {
# do stuff
}

for ( $scalar =~ /.*\n/g ) {
    # do stuff
    }


John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order.                            -- Larry Wall

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to