SPUG:Best One-Liners and Scripts for UNIX
John W. Krahn
krahnj at acm.org
Thu Apr 17 17:03:11 CDT 2003
On Thursday 17 April 2003 06:48, Brian Hatch wrote:
> > > function sp {
> > > $PERL5 -ape 'chomp @F; $_=join(" ",grep /./,
> > > @F['$fields'])."\n"' $@
> >
> > That could be simplified to:
> >
> > $PERL5 -lape'$_="@F['$fields']"' $@
>
> The reason for the grep was to allow laziness:
>
> sp 5..9999 /some/file
>
> so you didn't need to actually count the fields to say "everything
> from field #5 and therafter" and didn't get thousands of " " chars at
> the end of each line. Optimal? Nah. Ugly? Yeah. Works? Yeah.
Ah yes, trailing whitespace.
$PERL5 -lape'($_="@F['$fields']")=~s/\s+$//' $@
:-)
John
--
use Perl;
program
fulfillment
More information about the spug-list
mailing list