From: "Jeff Westman" <[EMAIL PROTECTED]> > Simple question here. I need to decrement a character "counter". > Incementing works fine, but not decrementing. > > I have: > > #!/bin/perl > use warnings; > $var = 'm'; > > print "var was $var\n"; > $var++; > print "var was $var\n"; > --$var; > print "var is $var\n"; > > > And I get: > > 0: rc-hp18:/home/dnxjjw5/dev > $ x2.pl > var was m > var was n > var is -1 > > I expected to see "var is m" in the last line.
++ is magical enough, -- is not. But if it's a single character you can use ord() and chr(). $var = chr(ord($var)-1) not as nice, I agree. Jenda ===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz ===== When it comes to wine, women and song, wizards are allowed to get drunk and croon as much as they like. -- Terry Pratchett in Sourcery -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/