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.
On 10/28/07, Mahurshi Akilla <[EMAIL PROTECTED]> wrote:
> is there a way to get the "nth" column of a string in perl, similar to
> awk '{print $col_no}' in awk ?
snip
If I remember my awk correctly $col_no (e.g. $2) gives you the nth
space delimited field in the string (counting multiple spaces as
Mahurshi Akilla wrote:
>
> is there a way to get the "nth" column of a string in perl, similar to
> awk '{print $col_no}' in awk ?
AWK does not have a 'col_no' variable so what is it that you are trying
to do?
I assume that you meant:
awk '{print $2}'
which would print the second field of the
is there a way to get the "nth" column of a string in perl, similar to
awk '{print $col_no}' in awk ?
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/