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.