Here is my regex
my ( $peer, $ip, $type, $mask, $port, $status ) = ( $line =~ /
^ # Start of line
([\w\d\-_\.]+) # First capture, peer name
\/?\s+? # Optional trailing slash, optional space
\(? # Optional opening parenthesis
([\w\d\.]+) # Second capture, IP address
\)? # Optional closing parenthesis
\s+?\(? # Optional space, optional open parenthesis
([\w]+) # Third capture, type
\)?\s+? # Optional closing parenthesis, optional space
([\d\w\.]+) # Forth capture, mask
\s+? # Optional space
([\d\w\.]+) # Fifth capture, port
\s+? # Optional space
([\d\w\.]+) # Final capture, status
$ # End of line
/x );
Works with this:
rpc-pbx-per-01/ 10.46.26.252 (S) 255.255.255.255 4569 UNREACHABLE
Does not work with this:
rpc-pbx-glb-01/ (Unspecified) (S) 255.255.255.255 4569 UNKNOWN