On 4/27/07, Jeff Pang <[EMAIL PROTECTED]> wrote:
> umm, why are you testing twice? Just capture the last digit (instead
> of the whole version number) in the first regex.
>
>next unless /\s+\d+\.\d+\.(\d+)\s+/;
>print "$1\n"
>
b/c he asked two questions,
1) how to capture version string
Hi,
is your version allways number dot number dot number? or can it be..
e.g. 1.2.1a or 1.6
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/
umm, why are you testing twice? Just capture the last digit (instead
of the whole version number) in the first regex.
next unless /\s+\d+\.\d+\.(\d+)\s+/;
print "$1\n"
b/c he asked two questions,
1) how to capture version string;
2) how to capture last number from version string.
surel
On 4/27/07, Jeff Pang <[EMAIL PROTECTED]> wrote:
open FILE,$file or die $!;
while () {
next unless /\s+(\d+\.\d+\.\d+)\s+/;
my $version_str = $1;
my ($lastnum) = $verison_str =~ /.*\.(\d+)/;
print $lastnum,"\n";
}
close FILE;
snip
umm, why are you testing twice? Just capture th
On 4/27/07, Tatiana Lloret Iglesias <[EMAIL PROTECTED]> wrote:
thanks a lot!!
And how can I locate the version String it self in the file?
bla bla bla
bla bla bla 1.2.0 bla bla
bla bla bla
my pattern is number.number.number
snip
Loop over the lines of the file applying the regex as you go:
open FILE,$file or die $!;
while () {
next unless /\s+(\d+\.\d+\.\d+)\s+/;
my $version_str = $1;
my ($lastnum) = $verison_str =~ /.*\.(\d+)/;
print $lastnum,"\n";
}
close FILE;
(Note for no test.)
2007/4/27, Tatiana Lloret Iglesias <[EMAIL PROTECTED]>:
thanks a lot!!
And how can I
thanks a lot!!
And how can I locate the version String it self in the file?
bla bla bla
bla bla bla 1.2.0 bla bla
bla bla bla
my pattern is number.number.number
Thanks!
T
On 4/27/07, Jeff Pang <[EMAIL PROTECTED]> wrote:
2007/4/27, Tatiana Lloret Iglesias <[EMAIL PROTECTED]>:
> Hi all!
>
>
2007/4/27, Tatiana Lloret Iglesias <[EMAIL PROTECTED]>:
Hi all!
how can I create a regular expression to find a software version pattern in
a file (e.g. 1.2.0) and return the last number , i.e. 0
Hi,
What's the form of your version string?
Given the case of $version_str = '1.2.0',you may wri
Hi all!
how can I create a regular expression to find a software version pattern in
a file (e.g. 1.2.0) and return the last number , i.e. 0
Thanks!
T