From the below out put i want to pattern match " thread id : from first and second set of line output. store the pattern in two different array and want to compare the same.
(in)* : 2000:0:0:0:0:0:0:1/2026 -> 4000:0:0:0:0:0:0:1/2026;17, Conn Tag: 0x0, VRF GRP ID: 0(0), If: vms-2/0/0.16392 (4045), CP session Id: 0, CP sess SPU Id: 0, flag: 600023:c0, wsf: 0, diff: 0, FCB: 0
npbit: 0x0 thread id:23, classifier cos: 0, dp: 0, is cos ready: No, sw_nh: 0x0, nh: 0x0, tunnel_info: 0x0, pkts: 36935, bytes: 2807060
usf flags: 0x10, fabric endpoint: 16
pmtu : 9192, tunnel pmtu: 0
(out) : 2000:0:0:0:0:0:0:1/2026 <- 4000:0:0:0:0:0:0:1/2026;17, Conn Tag: 0x0, VRF GRP ID: 0(0), If: vms-2/0/0.0 (20429), CP session Id: 0, CP sess SPU Id: 0, flag: 600022:c0, wsf: 0, diff: 0, FCB: 0
npbit: 0x0 thread id:255, classifier cos: 0, dp: 0, is cos ready: No, sw_nh: 0x0, nh: 0x0, tunnel_info: 0x0, pkts: 0, bytes: 0
usf flags: 0x0, fabric endpoint: 16
pmtu : 9192, tunnel pmtu: 0
I written the code like below and got the output in $1. but not able to seperate the numbers from the $1 output to compare
my $file = '/homes/rageshp/PDT/SPC3/vsp_flow_output1.txt';
open(FH, $file) or die("File $file not found");
while(my $String = <FH>)
{
if($String =~ /thread id:(\d+)/)
{
print "$1 \n";
}
}
close(FH);
my @thrid = $1;
print "$thrid[0]";