Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: If statement not working

by andye (Curate)
on Aug 24, 2012 at 14:54 UTC ( [id://989562]=note: print w/replies, xml ) Need Help??


in reply to If statement not working

It's because of your final statement, here:

if ($colr =~'light purple') { $trimmedcolr = 'LP'; } else { $trimmedcolr = $colr; }

(I've tidied it up a bit to make it clearer).

What you're saying with that is:

IF it's "light pink" then set trimmedcolr to 'LP' ELSE (if it's not "light pink") then set trimmedcolr to colr.
So, if any of the statements before that final one match, then 'light pink' won't match and so the ELSE part of that final statement will be executed.

e.g. if the colour is 'hot pink' then $trimmedcolr will be set to 'HP' and then set right back to $colr (in the bottom line).

HTH!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (2)
As of 2024-04-26 04:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found