in reply to Using both line mode and paragraph mode in the same program
I think local would be your best friend here. You probably can do what you need by defining well contained subroutines which affect the line separator in a minimum scope and then your programming will switch transparently between line and paragraph modes.
Something like this
Warning: The above code is untested.sub read_line { my $h = shift; local $/ = "\n"; return <$h> } sub read_para { my $h = shift; local $/ = ""; return <$h>; } use Fatal qw(open); open H, '<', 'files.csv'; while (my $txt = read_file(*H)) { # process the CSV line and make the filename available in $fn open TXT, '<', $fn; my @paragraphs = read_para(*TXT); # process }
Update: ikegami (at Re^2: Using both line mode and paragraph mode in the same program) pointed how "\n\n" is the wrong way to get paragraph mode (as can be read in the docs he mentioned). So I got it right with "".
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Using both line mode and paragraph mode in the same program
by ikegami (Patriarch) on Mar 27, 2007 at 15:45 UTC |