Here's one of many ways. Caveat, if any of your commands or locations contain '|', use a character they don't contain.
my @array = ( 'north#library' , 'south#kitchen', 'east#hallway'); my $cmd = 'south'; (my $location) = join('|', @array) =~ m[$cmd\#(.*?)\|]; print $location; kitchen
Examine what is said, not who speaks.
The 7th Rule of perl club is -- pearl clubs are easily damaged. Use a diamond club instead.
In reply to Re: array games??
by BrowserUk
in thread array games??
by eoin
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |