Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

Re: If statement not working

by andye (Curate)
on Aug 24, 2012 at 14:54 UTC ( #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).


Comment on Re: If statement not working
Select or Download Code

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2016-05-27 09:24 GMT
Find Nodes?
    Voting Booth?