"Jenda Krynicky" schreef: > Having a string like this: > > $version = 'Version: 1.47.785'; > > increment the last number. I seriously doubt you can do anything even > remotely as simple as > > $version =~ s/^(Version:\s*(?:\d+\.)*)(\d+)/$1 . ($2+1)/e;
- never trust your own (often temporary) definition of simple. - be careful when to use \d, that set can contain more than 100 characters. - you are using string evaluation. (read perlretut again) - you don't offer an easy choice of which part to increment. Alternative way, without string evaluation, using split with a simple regex: #!/usr/bin/perl use strict; use warnings; my $version = 'Version: 1.47.785'; my @parts = split /[.]/, $version; ++$parts[-1]; $version = join ".", @parts; print $version, "\n"; __END__ > Make sure it works for > > $version = 'Version:1.47.789'; > > as well. Without string eval() if I may ask. Make sure it works for 1.02.003 as well, without string eval, and with easy choice of incrementing what part. So version_inc("Version:1.02.003", -2, 1) should return "Version:1.03.000". And version_inc(" Version : 1.02.003 ", 1, 1) should likely return " Version : 2.00.000 ". Without cvs if I may ask. -- Affijn, Ruud "Gewoon is een tijger." -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/