is there a way to get the "nth" column of a string in perl, similar to
awk '{print $col_no}' in awk ?

###############################

There are multiple ways, but here are two examples:
In the first example, split is what you need to pay attention to.
In the second example,  @F is the key here. 

$ perl -le 'my $string = qq(a b c d); print $string; print +(split)[2,3], for 
$string;'
a b c d
cd

$ echo "a b c d"| perl -nae 'print "@F[2,3]\n";'
c d





__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to