$ver = $ver +1; $command =~ s//$ver/; #can be rewritten as: $command =~ s//++$ver/e;