#!/usr/bin/perl -w # Purple number stuff. use strict; my $nid = '0'; my $k = 0; while ($k++ < 1000) { $nid = increment_nid($nid); print "$nid\n"; } exit (0); # ------------------------------------------------------------------------ sub increment_nid { my $old_nid = shift; my @oldValues = split('', $old_nid); my @newValues; my $carryBit = 1; foreach my $char (reverse(@oldValues)) { if ($carryBit) { my $newChar; ($newChar, $carryBit) = _incChar($char); push(@newValues, $newChar); } else { push(@newValues, $char); } } push(@newValues, '1') if ($carryBit); return join('', (reverse(@newValues))); } # ------------------------------------------------------------------------ sub _incChar { my $char = shift; if ($char eq 'Z') { return '0', 1; } if ($char eq '9') { return 'A', 0; } if ($char =~ /[A-Z0-9]/) { return chr(ord($char) + 1), 0; } }