===================================== Need to have below output but output is not coming. Desired Output:- =====================================use strict; my $cmd="netstat >>C:\\perl-program\\test2\\netstat_ouput.txt"; system($cmd); my $file_name="netstat_ouput.txt"; my $pattern='WXP-DPBG8BS\s*:\s*(\d?\d?\d?\d?\d?)'; open(FH,"$file_name") or die "Could not able to open the file !"; while(<FH>) { my $line=$_; #print "$_\n"; if ($line=~m/$pattern/) { print "$line\n"; my @list=split $pattern,$line; print "Match is found ->!\n"; our @array=split ':',@list; foreach my $port(@array) { print "Port found:$port\n"; #print "Test\n"; } } else { print "No Match\n"; } } <c> =========================== netstat_output.txt ===========================<c> Proto Local Address Foreign Address State TCP WXP-DPBG8BS:1054 localhost:5354 ESTABLISHED TCP WXP-DPBG8BS:1440 localhost:27015 ESTABLISHED TCP WXP-DPBG8BS:1447 localhost:1448 ESTABLISHED TCP WXP-DPBG8BS:1448 localhost:1447 ESTABLISHED TCP WXP-DPBG8BS:5354 localhost:1054 ESTABLISHED TCP WXP-DPBG8BS:27015 localhost:1440 ESTABLISHED
===================================== Can you please help me to fix the code ?port found:3743 port found:3744 port found:3745 port found:3746 ..............
In reply to Extract Port value from netstat file by saikat
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |