Don't ask to ask, just ask | |
PerlMonks |
Re^2: Found a Perl holeby shenme (Priest) |
on Jan 27, 2005 at 18:14 UTC ( [id://425672]=note: print w/replies, xml ) | Need Help?? |
You have written quite a lot of code here. It is very confusing to us because of the great number of 'unusual' ways you implement things.
I think it would help you if you would check some of your assumptions on how Perl code works. When in doubt I start up perl in the debug mode and try out a line or two. Such as: This is me trying out that expression you were confused about. I find out that chr(127) does indeed convert the number into a string character. I then check what int(chr(127)) gives me - zero! Hmmm, doing an int() on a string that doesn't start with a number returns zero. Just to check what bart mentioned I try ord() and see that that is the reverse of what chr() does (which is why he mentioned it). So I directly tested that part of the problem expression and find out it will _always_ give me zero. But the array types doesn't always have numbers in it (so that '==' would be appropriate) nor does it always have characters in it (so that 'eq' would be appropriate). Compare these lines: In the first you force the value to be a character, but in the second you ask for the value as an integer. So neither '==' nor 'eq' are going to always work for the values in @types.
In Section
Seekers of Perl Wisdom
|
|