in reply to Can anyone tell me what is going on with my code?(Regex match variables)
before the substitution on $mac1.$mac2 = $2;
I.e.:
The substitution:if ($macs[1] =~ /(\S{17})\|(\S{17})/) { print "$macs[0] MAC1: $1\n"; print "$macs[0] MAC2: $2\n"; $mac1 = $1; $mac2 = $2; $mac1 =~ s/:/-/g; $mac2 =~ s/:/-/g; print "Converted Mac1: $mac1 Mac2: $mac2\n"; }
which is a new regex, is basically clearing $2 and making it undefined.$mac1 =~ s/:/-/g;
update: fixed two missing characters while copying and pasting the original code to change it. Thanks to AnomalousMonk for pointing out.
|
|---|