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

Re: Trying to compare a string...

by choroba (Canon)
on Oct 18, 2013 at 08:10 UTC ( #1058719=note: print w/ replies, xml ) Need Help??


in reply to Trying to compare a string...

That's not how || works. The general pattern is

condition || condition || condition

So, you have to repeat the whole condition each time:

if ($genres[0] eq 'Science Fiction' || $genres[0] eq 'Sci-Fi' || or $g +enres[0] eq 'Fantasy') {

If you think it is a bit verbose, switch to some other way of checking the values:

# Either if ($genres[0] =~ /^ (?: Science\ Fiction | Sci-Fi | Fantasy ) $/x) { # or if (grep $genres[0] eq $_, 'Science Fiction', 'Sci-Fi', 'Fantasy') {

etc.

لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ


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

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2015-07-05 16:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

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









    Results (67 votes), past polls