in reply to printing alternate lines from a file

If your data is absolutely regular, 4 records at a ttime, you could use something like this to simplyfy processing, in your read loop:
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.
Usual 'untested' disclaimer.

             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
    Thanks NetWallah for the reply..