in reply to Re^4: POE - can't increment within sub
in thread POE - can't increment within sub
Sorry, a numeric comparison won’t work correctly here:
#! perl use strict; use warnings; my $sequence_number = "01"; print $sequence_number, "\n"; for (1 .. 105) { if (++$sequence_number > 99) { $sequence_number = "01"; } print $sequence_number, "\n"; }
Output:
14:20 >perl 1479_SoPW.pl 01 02 3 4 5 6 7 8 9 10 11 12 ... 97 98 99 01 02 3 4 5 6 7 14:20 >
The reason is given in the documentation I quoted above:
If you increment a variable that is numeric, or that has ever been used in a numeric context, you get a normal increment. (emphasis added)
:-(
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
|
|---|