-3

I had two mac addresses 12-23-34-RT-43-23 and 12:23:34:rt:43:23. How to compare these two mac address in Perl. Are there any libraries to compare?

sam
  • 73
  • 7

1 Answers1

1

How about normalization, make them both upper case, and convert - to :,

my $mac1 = "12-23-34-RT-43-23";
my $mac2 = "12:23:34:rt:43:23";

y|[a-z]-|[A-Z]:| for $mac1, $mac2;

print "equal\n" if $mac1 eq $mac2;
mpapec
  • 50,217
  • 8
  • 67
  • 127
  • Are there any perl libraries? And can u explain the line "y|[a-z]-|[A-Z]:| for $mac1, $mac2;" once. – sam May 06 '15 at 06:36