|
|
| Pathologically Eclectic Rubbish Lister | |
| PerlMonks |
Re: Array splittingby AnomalousMonk (Prior) |
| on Oct 31, 2012 at 22:00 UTC ( #1001750=note: print w/ replies, xml ) | Need Help?? |
|
... it skips the if in the foreach loop. When I run your OPed code, I see that the else (false) clause of the conditional statement is skipped, not the if (true) clause, which is always executed. The reason is that you are using a numeric == comparison to test for string equality. You should use the eq operator (see Equality Operators in perlop). Numeric comparisons of strings that have no leading decimal digits are always equal because such strings always evaluate to zero in numeric context.
And BTW: using warnings would have alerted you to this problem, and using strict ain't a bad idea, either.
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||