in reply to alphanumeric autoincrement?
Here are a couple of useful OO type functions
%taps; $taps{'T1'}++; print "New taps, same level\n"; print new_tap('T1')," " for (0..15); print "\nNew taps, new level\n"; print new_level('T1')," " for (0..30); sub new_tap { my $tap = shift; my ($root, $end)= $tap =~ m/^(\w+?)([\d]+|[A-Z]+)$/i; my $new; { $new = $root.$end; if (exists $taps{$new}) { $end++; redo; } $taps{$new}++; } return $new; } sub new_level { my $tap = shift; my ($root, $end)= $tap =~ m/^(\w+?)([\d]+|[A-Z]+)$/i; my $suf = ($end =~ m/[0-9]/) ? 'A' : '1'; { $new = $root.$end.$suf; if (exists $taps{$new}) { $suf++; redo; } $taps{$new}++; } return $new; }
cheers
tachyon
s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print
|
|---|