Simplest way to match array of strings to search in perl?
Posted
by Ben Dauphinee
on Stack Overflow
See other posts from Stack Overflow
or by Ben Dauphinee
Published on 2010-06-11T01:49:41Z
Indexed on
2010/06/11
2:02 UTC
Read the original article
Hit count: 335
What I want to do is check an array of strings against my search string and get the corresponding key so I can store it. Is there a magical way of doing this with Perl, or am I doomed to using a loop? If so, what is the most efficient way to do this?
I'm relatively new to Perl (I've only written 2 other scripts), so I don't know a lot of the magic yet, just that Perl is magic =D
Reference Array: (1 = 'Canon', 2 = 'HP', 3 = 'Sony')
Search String: Sony's Cyber-shot DSC-S600
End Result: 3
© Stack Overflow or respective owner