perl_mystery has asked for the wisdom of the Perl Monks concerning the following question:
Everything was working a while back until I came across two paths like below mentioned in @txt, for some reason my below program is not giving anyoutput, all I am trying to do is in the two paths provided in @txt ,I am trying to see if there is a line that contains "branch from",if there is such a match get the p4 path based on a regex(I verified this regex to be working when I pass only the "branch from"line instead of the complete path shown in @txt. Need perl monks input on why is it not matching now?I have provided the input and sample output below.
#!/usr/bin/perl use strict; use warnings; use diagnostics; my @txt=("//perl/tools/files/data/HFAT_01_01/src/VU_CORE_STORAGE_HFAT. +01.01.36.txt ... #1 change 1508970 branch on 2010/11/08 by user (ktext) 'New Featur +es: None. Fixes: Upd' ... ... branch from //perl/tools/files/data/HFAT_01_01/src/VU_CORE_STO +RAGE_HFAT.01.01.35.txt#1 ... ... branch into //perl/tools/files/data/HFAT_01_01/src/VU_CORE_STO +RAGE_HFAT.01.01.37.txt#1", "//depot/asic/msmshared/umts/wcdma/rrc_temp/temp_76xx/temp_13505D/rrcr +bcommon.c ... #1 change 1528566 add on 2010/11/23 by user (ktext) 'Added code to + avoid bufferoverf' ... ... branch from //perl/tools/files/modem/rrc/main/latest/src/rrcrb +common.c#1,#25"); foreach my $line (@txt) { print "$line\n"; if ($line =~ /branch from/) #seems like the string "branch from" is no +t matching since $1 below prints nothing { #print ">>>$1<<<\n"; my ($update_p4path, $ver) = $line =~ /branch from (.*\/.*?)(?:#\d+,)?( +#\d+)$/; print "\n$update_p4path\n"; } } #OUTPUT SHOULD BE:- #//perl/tools/files/data/HFAT_01_01/src/VU_CORE_STORAGE_HFAT.01.01.37. +txt#1 #//perl/tools/files/modem/rrc/main/latest/src/rrcrbcommon.c#25 #OUTPUT SHOULD BE:- #//perl/tools/files/data/HFAT_01_01/src/VU_CORE_STORAGE_HFAT.01.01.37. +txt#1 #//perl/tools/files/modem/rrc/main/latest/src/rrcrbcommon.c#25
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Match problem
by BrowserUk (Patriarch) on Dec 22, 2010 at 01:01 UTC | |
|
Re: Match problem
by toolic (Bishop) on Dec 22, 2010 at 01:03 UTC | |
by perl_mystery (Beadle) on Dec 22, 2010 at 01:18 UTC | |
by perl_mystery (Beadle) on Dec 22, 2010 at 01:42 UTC | |
by oko1 (Deacon) on Dec 22, 2010 at 02:49 UTC | |
|
Re: Regex problem
by Anonymous Monk on Dec 22, 2010 at 05:32 UTC |