#!/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 Features: None. Fixes: Upd' ... ... branch from //perl/tools/files/data/HFAT_01_01/src/VU_CORE_STORAGE_HFAT.01.01.35.txt#1 ... ... branch into //perl/tools/files/data/HFAT_01_01/src/VU_CORE_STORAGE_HFAT.01.01.37.txt#1", "//depot/asic/msmshared/umts/wcdma/rrc_temp/temp_76xx/temp_13505D/rrcrbcommon.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/rrcrbcommon.c#1,#25"); foreach my $line (@txt) { print "$line\n"; if ($line =~ /branch from/) #seems like the string "branch from" is not 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