"Jenda Krynicky" schreef:
> Dr.Ruud:
>> Matthew Whipple:
>>> Dr.Ruud:
>>>> Tatiana Lloret Iglesias:

>>>>> What regular expression do I need to convert
>>>>> Version: 1.2.3   to
>>>>> Version: 1.2.4  ?
>>>>>
>>>>> I.e.  my pattern is Version: number.number.number and from that i
>>>>> need Version: number.number.number+1
>>>>> After the : i can have a space or not...
>>>>
>>>> Why use a regex?
>>>>
>>>> perl -wle '
>>>>     $v = 2.1.1;
>>>>     printf "%vd\n", $v;
>>>>     substr $v, -1, 1, chr ord(substr $v, -1, 1) + 1;
>>>>     printf "%vd\n", $v
>>>> '
>>>>
>>>> See also version.pm
>>>
>>> This wouldn't scale past double digits.
>>
>> Why not?
>>
>> $ perl -wle '
>>     $v = 1.23456.777888999;
>>     printf "%vd\n", $v;
>>     substr $v, -1, 1, chr ord(substr $v, -1, 1) + 1;
>>     substr $v, -2, 1, chr ord(substr $v, -2, 1) + 1;
>>     printf "%vd\n", $v
>> '
>> 1.23456.777888999
>> 1.23457.777889000
>
> Well this is a bit tricky. The OP doesn't have a
>     $version = 1.2.3
> , he has a string
>     $v = 'Version: 1.2.3'

This was about 'double digits', more than about anything else.

The "Matthew Whipple" who doesn't know about how to properly mix his
reply with the text he replies on, also doesn't know about Perl
characters.


> Try
>
>     print( (1.2.3 eq '1.2.3') ? 'yes' : 'no');

$ perl -wle 'print sprintf("%vd", 1.2.3) eq "1.2.3" ? "y" : "n"'
y

-- 
Affijn, Ruud

"Gewoon is een tijger."


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to