A
Awkish
Hi,
I must parse files of this form:
field1,,,field4,,field6,,,,,,
That is, the fields of each line are separated by a comma, and the fields
can be empty.
With awk I can do this:
awk -F, '{print $6; print NF}'
with the above line I get:
field6
12
and that's what I want
How can I get the same result with Perl?
I tried:
perl -F, 'print $F[5];print $#F+1'
which gives:
field6
5
Perl drops the "empty" fields after the last non-empty field :-(
I must parse files of this form:
field1,,,field4,,field6,,,,,,
That is, the fields of each line are separated by a comma, and the fields
can be empty.
With awk I can do this:
awk -F, '{print $6; print NF}'
with the above line I get:
field6
12
and that's what I want
How can I get the same result with Perl?
I tried:
perl -F, 'print $F[5];print $#F+1'
which gives:
field6
5
Perl drops the "empty" fields after the last non-empty field :-(