SPUG: auto-increment mixed alpha-numeric
Richard Wood
wildwood_players at yahoo.com
Thu Mar 13 13:01:42 CST 2003
I have the need/desire to auto-increment a three
character scalar that may contain: all numerics, all
alphas, or mixed alpha-numeric.
auto-increment works fine for all alpha and all
numeric and in some cases with a mix of alpha-numerics
but not when a numeric precedes an alpha. In those
cases I get two types of results. (e.g. '1AA' becomes
2, 'A1A' becomes 1, then 2).
Anyone have a simple solution to this? I will
continue to look around and try things but I thought I
would ask the community before any more time slipped
away.
Here is my test program and results:
#!/usr/bin/perl -w
@strings = qw(AAA AA8 A8A A98 118 18A 1A8 8AA);
foreach $str (@strings) {
for ($i=0;$i<3;$i++) {
print "$str\t";
$str++;
}
print "\n";
}
__END__
AAA AAB AAC
AA8 AA9 AB0
A8A 1 2
A98 A99 B00
118 119 120
18A 19 20
1A8 2 3
8AA 9 10
Regards,
Rich Wood
=====
Richard O. Wood
Wildwood IT Consultants, Inc.
wildwood_players at yahoo.com
425.281.1914 mobile
206.544.9885 desk
__________________________________________________
Do you Yahoo!?
Yahoo! Web Hosting - establish your business online
http://webhosting.yahoo.com
More information about the spug-list
mailing list