SPUG:Best One-Liners and Scripts for UNIX

SPUG-list-owner tim at consultix-inc.com
Sat Apr 19 14:44:02 CDT 2003


On Sat, Apr 19, 2003 at 10:37:13AM -0700, Tim Maher wrote:

This version has the corrected Usage messasge (the compiler
missed that mistake! 8-})

-Tim
> 
> BEGIN {
> 	# first argument contains comma-separated field numbers
> 	# order of numbers determines order of printing fields
> 	($fields = shift) =~ /^[\d,.]+$/g or
		die "Usage: fields='2,1,3,4..7' $0 [ file ... ]"; #BAD
 		die "Usage: $0 '2,1,3,4..7' [ file ... ]"; #GOOD
> 	@fields = eval " ( $fields ) ";	# 5,2..4 => 5,2,3,4
> }
> 
> @F or next;	# skip blank lines
> # Let user specify from #1
> unshift @F, "(No zeroth field! first is #1)";
> print  "@F[ @fields ]"; 
> 
> 
> -Tim
> *------------------------------------------------------------*
> |  Tim Maher (206) 781-UNIX  (866) DOC-PERL  (866) DOC-UNIX  |
> |  CEO, JAWCAR ("Just Another White Camel Award Recipient")  |
> |  tim at Consultix-Inc.Com  TeachMeUnix.Com  TeachMePerl.Com   |
> *+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-*
> |  Watch for my  Book: "Minimal Perl for Shell Programmers"  |
> *------------------------------------------------------------*
> _____________________________________________________________
> Seattle Perl Users Group Mailing List  
> POST TO: spug-list at mail.pm.org
> ACCOUNT CONFIG: http://mail.pm.org/mailman/listinfo/spug-list
> MEETINGS: 3rd Tuesdays, U-District, Seattle WA
> WEB PAGE: www.seattleperl.org

-- 

-Tim
*------------------------------------------------------------*
|  Tim Maher (206) 781-UNIX  (866) DOC-PERL  (866) DOC-UNIX  |
|  CEO, JAWCAR ("Just Another White Camel Award Recipient")  |
|  tim at Consultix-Inc.Com  TeachMeUnix.Com  TeachMePerl.Com   |
*+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-*
|  Watch for my  Book: "Minimal Perl for Shell Programmers"  |
*------------------------------------------------------------*



More information about the spug-list mailing list