in reply to Extract Port value from netstat file

Hi, here is your solution:
while (defined(my $line = <FH>)) { if ($line =~ m/$pattern/) { printf "Port found: %d\n", (split $pattern, $line)[1]; } else { print "No Match\n"; } }
P.S.: In the future, please use <code>...</code>.