Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Trying to compare a string...

by hdb (Prior)
on Oct 18, 2013 at 08:49 UTC ( #1058730=note: print w/replies, xml ) Need Help??


in reply to Trying to compare a string...

If you combine kcott's and moritz's answers, you could put the regexes into a hash and then test against that.

use strict; use warnings; my %genre_table = ( 'Sci-Fi & Fantasy' => qr/Science Fiction|Sci-Fi|Fantasy/, 'Action & Adventure' => qr/Action|Adventure|War/, 'Kids & Family' => qr/Kids|Family/, ); my @genres = ( 'Adventure' ); my( $genre ) = ( ( grep { $genres[0] =~ $genre_table{$_} } keys %genre +_table ), $genres[0]); print $genre;

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1058730]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (10)
As of 2016-09-27 14:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Extraterrestrials haven't visited the Earth yet because:







    Results (506 votes). Check out past polls.