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.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.