After you've opened *IN from the input file and *OUT to the output, use the $. variable to tell you how many lines have been read.
which will print odd-numbered lines to OUT. Replace if with unless to print even lines.while (<IN>) { print OUT $_ if 1 & $. ; }
Update: Corrected typo.
After Compline,
Zaxo
In reply to Re: How to Print Every Other Line
by Zaxo
in thread How to Print Every Other Line
by Neuroactive
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |