(C) 2003, Tim Maher 1-27 www.TeachMePerl.com Field Extraction Script (cont.) show_fields2c #! /usr/bin/perl -wlna BEGIN { $Usage="$0 '2,1,4..7' [ f1 ... ]"; # Order of field numbers dictates print order $fields = shift; # first field specified as 1 $fields =~ /^[\d,.]+$/g or die "$Usage\n"; # convert 5,2..4 => 5,2,3,4 @fields = eval " ( $fields ) "; } @F > 0 or next; # skip if no fields on line unshift @F, "(No zeroth field! first is #1)"; print "@F[ @fields ]"; # SP-separated fields