in reply to Re: parse a string
in thread parse a string

Here is the split way for Anony:
my $string = "something, something, something, this"; my $lastword = ( split(/\s*,\s*/, $string) )[-1];
First, you split on a comma, but since there is whitespace involved, i chose to use a regex that says "zero or more whitespace followed by a literal comma followed by zero or more whitespace". Since split returns a list, you can take advantage and add an index on the spot without using a temporary variable (well, sort of). In this case the index is -1, which is the last element.

Of coures, this is not an efficient way to do it, but ... TIMTOWTDI! ;)

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)