If you are simply incrementing the most minor part of the version you might be able to automate it a bit by capturing that part of the version number and incrementing it in the substitution using the 'e' flag to execute a bit of code.
use strict; use warnings; use 5.010; my $rxSep = qr{[-_.]}; my @versions = qw{ 1.2.3.4 2.6 3_4_9 4-2-13-5 5 }; foreach my $version ( @versions ) { ( my $newVersion = $version ) =~ s{((?:\d+$rxSep)+)*(\d+)(?!$rxSep)} { my $ver = $2; ( defined $1 ? $1 : q{} ) . ++ $ver }e; say qq{$version => $newVersion}; }
The output.
1.2.3.4 => 1.2.3.5 2.6 => 2.7 3_4_9 => 3_4_10 4-2-13-5 => 4-2-13-6 5 => 6
I hope this is helpful.
Cheers,
JohnGG
In reply to Re: Search/Replace action using "."
by johngg
in thread Search/Replace action using "."
by rsperl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |