tchrist@convex.COM (Tom Christiansen) (05/16/91)
Here's a little head clone I once wrote out of frustration with head's misbehaving on files with long lines. #!/usr/bin/perl # # head -- perl clone of head command, but without heads silly # limits regarding line lengths. runs faster than # C version, too! tchrist@convex.com $num = ($ARGV[0] =~ /^-(.+)/ && shift) ? $1 : 10; die "$0: badly formed number: $1\n" unless $num =~ /^\d+$/; unshift(@ARGV, '-') unless $argc = @ARGV; # <> changes @ARGV while (<>) { if ($. == 1 && $argc > 1) { print "\n" if $deja_imprime++; print "=> $ARGV <=\n" ; } if ($. <= $num) { print; } else { close ARGV; } } -- Tom Christiansen tchrist@convex.com convex!tchrist "So much mail, so little time."