Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: How the auto-increment operator works?

by ikegami (Patriarch)
on Jul 31, 2020 at 13:47 UTC ( [id://11120139]=note: print w/replies, xml ) Need Help??


in reply to How the auto-increment operator works?

For the same reason that the following results in 100 instead of 00 (0).

$x = 99; ++$x;

If you exceed the range of the second position, it carries into the third position. To keep it to two digits, you need to take explicit action.

$x = 99; ++$x; $x %= 100;
$x = 'zz'; ++$x; $x = substr($x, -2);

Replies are listed 'Best First'.
Re^2: How the auto-increment operator works?
by zapdos (Sexton) on Aug 01, 2020 at 00:44 UTC
    Thank you so much for helping me, ikegami. ;-)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11120139]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (3)
As of 2024-04-19 02:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found