in reply to Re^2: How to increment a MAC Address?
in thread How to increment a MAC Address?

HEX to DEC
You mean convert a hex string to a number. It's not a decimal number until you print it for output. I don't see any place that you are stringifying it.

-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.

Replies are listed 'Best First'.
Re^4: How to increment a MAC Address?
by mda2 (Hermit) on Jun 16, 2005 at 17:47 UTC
    I did this:
    # clear separators to obtain a hex string $mac =~ s/://g; # convert hex string into a dec number my $dec = hex($mac); # revert into a hex string $mac = sprintf("%012x", $dec+$add);

    I don't see error here. I think it's used by context...

    --
    Marco Antonio
    Rio-PM

      # convert hex string into a dec number my $dec = hex($mac); # revert into a hex string $mac = sprintf("%012x", $dec+$add);
      My argument is with the word "dec" there. It's not decimal. It's just a number. In fact, it's more binary than it is decimal. {grin}

      The "hex" operator interprets a hex string or an octal string, converting them to a number. A number is an abstraction, without a numeric base, until it gets converted to a string again.

      Thus, you never really have a "decimal" number there. Just a number. Because you never printed it out.

      -- Randal L. Schwartz, Perl hacker
      Be sure to read my standard disclaimer if this is a reply.