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;
|
|---|