open FILE,$file or die $!; while (<FILE>) { 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 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! > > > > 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 write: > > my ($lastnum) = $verison_str =~ /.*\.(\d+)/; > > Good luck. > > -- > Chinese Practical Mod_perl book online > http://home.arcor.de/jeffpang/mod_perl/ >
-- Chinese Practical Mod_perl book online http://home.arcor.de/jeffpang/mod_perl/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/