2010/4/13 Magne Sandøy <msan...@gmail.com>: > Thanks for all the good info. I think I have a grasp on incrementing and > comparison, but now, what puzzles me, is the fact that when I use "le" less > than or equal, why does it actually increment the "z"? It is by then passed > the less than, and already at equal to "z". It should then just exit the > loop. > And just to add to my confusion, "ge" and "gt" does not give any output at > all. "u" is not greatier than "z", is it?
IIRC, you're referring to this loop (from the OP): > for ($_="u"; $_ le "z"; $_++){ > print " $_ "; > } Note that in for loops, the 'increment' (i.e., $_++) occurs before the condition ($_ le "z"). So when $_ is equal to "z", the condition passes (i.e., $_ is less than or /equal/ to "z"). Then $_ is "incremented" from "z" to "aa". This too is /less than/ or equal to "z" using a string comparison so it continues on until it reaches "za", which is not. You may be thinking of lt instead of le. If you used lt then when $_ was "z" it would fail the << $_ lt "z" >> condition and exit out of the loop right there. Because you're using le instead, you enable the string ordering to "wrap" back around to "aa", which starts a long process of "increments" before reaching something not less than or equal to the string "z". The reason gt and ge won't give any output at all is because $_ starts at "u", which is not greater than /nor/ equal to "z" so the condition fails right away. Forgive me if I'm misread you. -- Brandon McCaig <bamcc...@gmail.com> V zrna gur orfg jvgu jung V fnl. Vg qbrfa'g nyjnlf fbhaq gung jnl. Castopulence Software <http://www.castopulence.org/> <bamcc...@castopulence.org> -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/