Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

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;

Comment on Re: Trying to compare a string...
Download Code

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (8)
As of 2015-07-08 03:11 GMT
Find Nodes?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...

    Results (93 votes), past polls