[TriLUG] Perl question. . .

Michael Peters mpeters at plusthree.com
Tue Feb 17 15:17:11 EST 2009


Brian Henning wrote:
> There's undoubtedly a more elegant way...

Or at least a different way :)

]$ cat bin/pick
#!/usr/bin/perl
my $pick = shift;
while (<>) {
     if( $line++ == $pick ) {
         print $line;
         exit(0);
     }
}

And then you can use it like this:

]$ pick 2345 < sourcefile > destfile

-- 
Michael Peters
Plus Three, LP




More information about the TriLUG mailing list