Hello Charles, At 12:22 PM 10/31/2002 -0500, [EMAIL PROTECTED] wrote: > >I have a file that looks like >0 >232,32387,2323 > >I am only interested in the last set of digits on the second line. My plan >was to split on coma and take the 3 element of the array. I am having >problems skipping the fist line. Any assistance would be appreciated.
Let's assume you have the data in a file called foo: # perl -MEnglish -F"," -ane 'chomp @F; print $F[2], "\n" if $NR > 1 and $#F' foo Explanation of options: -MEnglish = loads the English module; needed for $NR (record number variable) -F = specify the regular expression to user for autosplit (-a) -a = autosplit the record (line) into array @F (makes perl work like awk) -n = read each line and apply script (makes perl work like awk) -e = read following command line argument as a script Explanation of script: remove the newline from array F [ chomp @F ] if split worked and the record number is greater than 1 [ if $NR > 1 ] then print the third item [ print $F[2], "\n" ] This one-liner will work on multiple files including stdin. 'perldoc perlrun' for more details. Regards, - Robert -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]