in reply to match last element instead of first??

You can pull out your words into an array by using captures in a global match, like this

use strict; use warnings; my $restOfLine = q{one fish two fish red fish blue fish}; my @words = $restOfLine =~ m{(\S+)\s+fish}g; print qq{$_\n} for @words;

which produces

one two red blue

I hope this is of use.

Cheers,

JohnGG