On Tue, Oct 08, 2002 at 10:00:09AM -0700, Anil Shekhar wrote: > Thanks Mark. > > I mean how is the following possible. > > print ++($foo = 'Az'); # prints 'Ba' > print ++($foo = 'zz'); # prints 'aaa'
(I'm obviously not Mark, but I figure I'll give this a shot) That's how the ++ operator works. Just like this works, print ++($foo = 9); # '10' print ++($foo = 999); # '1000' so do the examples with strings. In both of the examples you showed, the letters were being wrapped around to the next "highest" value. 'z' is at the end of the alphabet, it is wrapped around to 'aa' when it is incremented. According to Perl, the next "highest" string after 'z' is 'aa', and next highest after 'Az' is 'Ba' (notice that case is preserved and ignored in the string "value" calculations, so it's not just incrementing a numerical representation of the string), and the next highest after 'zz' is 'aaa'. It's possible because that's how it's implemented in Perl. Characters aren't numbers in Perl as blatantly as they are in C, but you can still use one of the numerical operators on them. > Thanks > Anil HTH, -- Michael -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]