good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
Re: counting number of filedsby SuperCruncher (Pilgrim) |
on Dec 09, 2002 at 20:10 UTC ( [id://218649]=note: print w/replies, xml ) | Need Help?? |
First of all, it seems like you need to read up on Perl. Try some of the things suggested at the Learn Perl site. 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.
In Section
Seekers of Perl Wisdom
|
|