SPUG:Best One-Liners and Scripts for UNIX

Brian Hatch spug at ifokr.org
Thu Apr 17 08:48:47 CDT 2003



> >   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.

And this was back when I was just starting to learn perl and hadn't
learned about -l yet.  (I love -l)

--
Brian Hatch                  He without humor
   Systems and                is unarmed.
   Security Engineer
http://www.ifokr.org/bri/

Every message PGP signed
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://mail.pm.org/pipermail/spug-list/attachments/20030417/69c8448e/attachment.bin


More information about the spug-list mailing list