You probably want something like this:
use warnings; use strict; my $cmd = 'netstat'; my $pattern = qr/WXP-DPBG8BS\s*:\s*(\d+)/; open my $PIPE, '-|', $cmd or die "Could not open the pipe from '$cmd' +because:$!"; while ( <$PIPE> ) { if ( /$pattern/ ) { print "port found: $1\n"; } } close $PIPE or warn $! ? "Error closing $cmd pipe: $!" : "Exit status $? from $cmd";
In reply to Re: Extract Port value from netstat file
by jwkrahn
in thread Extract Port value from netstat file
by saikat
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |