in reply to When every 2 lines of a file (sans first) should be 1...
Aren't you missing a chomp? Assuming so, sSomething like:
my $fh = open_file( 'filename' ); print read_first_line( $fh ); print read_two_lines( $fh ) until eof( $fh ); sub read_first_line { my $fh = shift; return scalar <$fh>; } sub read_two_lines { my $fh = shift; chomp(my $first = <$fh>); return $first . <$fh>; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: When every 2 lines of a file (sans first) should be 1...
by metaperl (Curate) on Dec 04, 2007 at 20:30 UTC |