in reply to printing alternate lines from a file
Usual 'untested' disclaimer.open my $file, "<" , "Filename" or die "$!"; my @buf; while (<$file>){ chomp; s/^\s*//; # Drop leading blanks s/\s*$//; # Drop trailing blanks if (0 == $. % 4){ # Processes the contents of @buf # it appears that something like this is what you need: print join(" ",@buf, $_), "\n"; @buf=(); # Reset it }else{ push @buf, $_; } } close $file; @buf and print @buf; # In case there is left-over stuff.
I hope life isn't a big joke, because I don't get it.
-SNL
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: printing alternate lines from a file
by perl_req (Initiate) on Sep 13, 2012 at 01:40 UTC |