in reply to counting number of fileds
split returns a list. You can store this list in an array, e.g. my @bits = split /,/, "foo,bar,baz";. In Perl, you can find out how many elements are in an array by doing scalar @array (or scalar @bits in this case). Subtract one to get the index of the last element. Anyway, you can get at the last three elements by doing: my (@last_three) = ($bits[-1], $bits[-2], $bits[-3]);
Hope this helps, but make sure you learn Perl properly. You'll thank yourself for it.
|
|---|