in reply to Increment a string with letters and numbers
G'day mrguy123,
The following substitution should do what you want:
s/(\d+)$/my $y = $1; ++$y/e
In use with your specific example:
$ perl -Mstrict -Mwarnings -E ' my $x = q{EVO:0000023}; $x =~ s/(\d+)$/my $y = $1; ++$y/e; say $x ' EVO:0000024
And, assuming you want 0000099 to roll over to 0000100, this works unchanged:
$ perl -Mstrict -Mwarnings -E ' my $x = q{EVO:0000099}; $x =~ s/(\d+)$/my $y = $1; ++$y/e; say $x ' EVO:0000100
-- Ken
In Section
Seekers of Perl Wisdom