I want to match the string which is followed by " ETN : " i.e., (name1/name2 ) first and after I match it, I want to print the first occurrence of it before the string "data reached"
ETN: name1/name2
abchsfk/jshflka/ZN (cellLVT)
asjkfsa/sfklfkshfsf/Z (mobSVT)
asjhfdjkfd/sjfdskjfhdk/hsakfshf/Z (celLVT)
asjhdjs/jhskjds/ZN (abcSVT)
shdsjk/jhskd/ZN (xyzSVT)
name1/name2/ZN (abcLVT)
data reached
asjhfdjkfd/sjfdskjfhdk/hsakfshf/Z (celLVT)
asjkfsa/sfklfkshfsf/Z (mobSVT)
shdsjk/jhskd/ZN (xyzSVT)
asjhdjs/jhskjds/ZN (abcSVT)
shdsjk/jhskd/ZN (xyzSVT)
name1/name2/ZN (abcLVT)
ETN: name3/name4
abchsfk/jshflka/ZN (cellLVT)
asjkfsa/sfklfkshfsf/Z (mobSVT)
asjhfdjkfd/sjfdskjfhdk/hsakfshf/Z (celLVT)
asjhdjs/jhskjds/ZN (abcSVT)
shdsjk/jhskd/ZN (xyzSVT)
name3/name4/ZN (fhLVT)
data reached
asjhfdjkfd/sjfdskjfhdk/hsakfshf/Z (celLVT)
asjkfsa/sfklfkshfsf/Z (mobSVT)
shdsjk/jhskd/ZN (xyzSVT)
asjhdjs/jhskjds/ZN (abcSVT)
shdsjk/jhskd/ZN (xyzSVT)
name3/name4/ZN (fhLVT)
Output :
name1/name2/ZN (abcLVT)
name3/name4/ZN (fhLVT)
CODE:
I tried to march the string first with ETN and tried to print it.
if ($line =~ m/ETN: /)
{
my @names = split / /, $line;
$a = $names[3];
if ($line =~ m /$a /)
{
print " $line \n" ;
}
}