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

In reply to Regex problem by perl_mystery

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.