Seems a good example of how every little question has some merit.  You just
never know.

I've had the same problem on Windows 2000 and have been using edit.com to find
line numbers in my scripts, and it isn't real handy; it opens a small window,
navigation is slow, etc.  There is probably a Windows port of vi, but I prefer
Notepad.

So Hewlett's question gave me an idea.  Just print my scripts to the screen
with line numbers added.  My life is now better.  Sure beats arrow-down
counting.

#!perl
# File db.pl (db stands for debug)
# Print script to screen with line numbers

$ARGV[0] or &Usage;

open (FILE,"< $ARGV[0]");
$c = 0;
while (<FILE>) {
        $c++;
        if ($ARGV[1] && ! $ARGV[2]) {
                next if $ARGV[1] != $c;
                print "$c  $_";
                last;
        } elsif ($ARGV[1] && $ARGV[2]) {
                if ($c >= $ARGV[1] - $ARGV[2]) {
                        print "$c  $_";
                        last if $c == $ARGV[1] + $ARGV[2];
                }
        } else {
                print "$c  $_";
        }
}
close FILE;

sub Usage {
print "
\tUsage:  db.pl scriptname.pl               ...All lines
\t   or:  db.pl scriptname.pl number        ...Specific line
\t   or:  db.pl scriptname.pl number number ...Specific line with context\n";
}

__END__

Dropping db.pl into path, it is always available.

In the DOS window I have the buffer set to max of 9999.  If my script reaches
10000 lines, well, nevermind.

(XP's Notepad includes lines numbers if status bar is turned on).

Gary

> -----Original Message-----
> From: Hewlett Pickens [mailto:[EMAIL PROTECTED]]
> Sent: Friday, January 11, 2002 12:34 PM
> To: Hanson, Robert; Hewlett Pickens; [EMAIL PROTECTED]
> Subject: RE: Line Numbers and Posting Archives
>
>
> Rob,
>
> Thank you for the quick reply on the line numbers.
<snip>
> ... face is slightly red ...



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to