Perl: the Markov chain saw | |
PerlMonks |
Re: If statement not workingby GrandFather (Saint) |
on Aug 25, 2012 at 01:05 UTC ( [id://989670]=note: print w/replies, xml ) | Need Help?? |
I'd use a hash to manage the colour/replacement pairs. Consider:
Prints:
Note that the sort is there so that pinkish is matched correctly rather then being matched by 'pink'. Depending on the order of your tests and the strings being tested you current code would suffer from the same problem.
True laziness is hard work
In Section
Seekers of Perl Wisdom
|
|