in reply to Can anyone tell me what is going on with my code?(Regex match variables)

Try to put the following line:
$mac2 = $2;
before the substitution on $mac1.

I.e.:

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"; }
The substitution:
$mac1 =~ s/:/-/g;
which is a new regex, is basically clearing $2 and making it undefined.

update: fixed two missing characters while copying and pasting the original code to change it. Thanks to AnomalousMonk for pointing out.