[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Numbering Lines in MacPerl



pudge@pobox.com, mkraft@pair.com, mac-perl@iis.ee.ethz.ch
Subj:	Re: [MacPerl] Numbering Lines in MacPerl

Chris Nandor wrote:

> At 09.29 -0400 1997.06.25, Matt Kraft wrote:
> >How do I number lines in MacPerl?  Whenever I run my script it says:
> >
> ># Missing right bracket, at end of line
> >File 'Untitled'; Line 928
> ># syntax error, at EOF
> >File 'Untitled'; Line 928
> ># Execution of Untitled aborted due to compilation errors.
> >
> >But I can't find line 928 so I can't fix it.
> 
> Editing the script in BBEdit, BBEdit Lite, Alpha, etc. allows quick access
> to line numbers.  It is not generally recommended to write large scripts in
> the MacPerl editor.

All true, but it is quite easy to get this job done:

#!perl
while(<>){print "$. $_"}
__END__

which is so small that it is hardly worth saving as a droplet.  
Another approach is to roll your own context grep on the fly like so:

#!perl
while(<>){print "$. $_" if ($. <= 930 && $. >= 926)}
__END__

>From the MPW command line (I think I have the quotation marks right here - but 
I am not at a Mac at this time :-):

 perl -ne 'print "$. $_" if ($. <= 930 && $. >= 926)' myscriptname

etc.

Peter Prymmer



***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch