I'm not clear when you say you're not getting the desired results. I did notice that you are first printing your $line
and then printing $mac_addr
afterwards, besides that your expression seems to match.
Your regular expression
matching your desired data.
If you simply just want the matches, you could do..
for my $line (@ver) {
if (my ($mac_addr) = $line =~ /((?:[0-9a-f]{4}\.){2}[0-9a-f]{4})/) {
print $mac_addr, "\n";
}
}
Output
782b.cb87.b085
c0ea.e402.e711
c0ea.e45c.0ecf
0050.5677.c0ba
c0ea.e400.9f91