On Jan 1, 2008 12:21 PM, yitzle <[EMAIL PROTECTED]> wrote: > You can skip the array assignment and just do: > > foreach ( split "\n", $scalar ) { > ... > } > > I predict a reply that uses map()... though I think that using a map > isn't really another solution, but just an alternative to the for > loop. > > map {stuff}, split "\n", $scalar; > > But I think the answer is basically as you said. Use split. > Then again, you ought to be able to open a pipe and print the scalar > to the pipe and use the: > while <HANDLE> > syntax. I'm not sure how exactly the newlines would get treated in > that scenario... snip
If you have a recent enough version of Perl* you can say open my $fh, "<", \$scalar or die "could not attach a file handle to \$scalar: $!"; while (my $line = <$fh>) { chomp($line); #do stuff with $line } * 5.8 can do this, but I am not sure about 5.6.* -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/