[TriLUG] Perl question. . .
Marc Wiatrowski
mwia at iglass.net
Tue Feb 17 16:35:51 EST 2009
Or how about
perl -ne '($ARGV[0]==$.)?print&&last:1;' <file> <pick>
or not perl
head -<pick> <file> | tail -1
:)
On Tue, 2009-02-17 at 15:54 -0500, Scott Lambdin wrote:
> yeah, but you are wasting a lot of cpu with all the decrementing.
> (snicker) How about
>
>
> #!/edi/perl/bin/perl
> my $pick = shift;
>
> while(<>) {
> if($pick == $.) {
> print $_;
> exit(0);
> }
> }
>
>
>
> On 2/17/09, Brian Henning <Brian.Henning at datadirect.com> wrote:
> >
> > Bollocks! Right you are.
> >
> >
> > Michael Peters wrote:
> >
> > >Brian Henning wrote:
> > >> I think what you really meant was this:
> > >
> > >> if($pick-- == 0) {
> > >
> > >Shift that to "--$pick == 0" and yes :)
> > >
> > >> ...which is of course what I really meant the first time.. :-)
> >
> > --
> > TriLUG mailing list : http://www.trilug.org/mailman/listinfo/trilug
> > TriLUG FAQ : http://www.trilug.org/wiki/Frequently_Asked_Questions
> >
>
>
>
> --
> There's a box?
More information about the TriLUG
mailing list