#/usr/local/bin/perl #From: tchrist@convex.COM (Tom Christiansen) #Subject: better head #Date: 16 May 91 15:23:56 GMT #Reply-To: tchrist@convex.COM (Tom Christiansen) #Organization: CONVEX Software Development, Richardson, TX #Nntp-Posting-Host: pixel.convex.com # #Here's a little head clone I once wrote out of frustration #with head's misbehaving on files with long lines. # # 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." # #