in reply to how to print first 5 lines of a file
#!/usr/bin/perl -w use strict; my $cnt = 0; while (my $line = <>) { chomp($line); $cnt++; if ($cnt > 5) { next; } else { print "$line\n"; } }
use strict; open(PRINT,"| lp") || die "Could not start lp : $!\n"; while (my $line = <>) { print PRINT $line; last if ($. > 5); } close(PRINT);
|
|---|