in reply to Re^2: Parsing multiline string line by line
in thread Parsing multiline string line by line
But that puts the whole file into the first element of the array. (Change your print to print "|$_|\n" for @fin; and you'll see only one element.)
You probably want this:
$/ = undef; open "FIN", "<raja.txt" or die "cant open :$!"; my @fin = split/\n/,<FIN>; close FIN; print "|$_|\n" for @fin;
Or to also get rid of blank lines:
... my @fin = grep {$_} split /\n/, <FIN>;
Update: Square brackets in my original post created a link I didn't intend. I changed them to pipes. And alternatively, you could just print scalar @fin to confirm how many items you slurped.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Parsing multiline string line by line
by Jayson (Novice) on Feb 20, 2009 at 14:35 UTC |