in reply to Concatenate and join
The intermediate atmac is not needed but is easy to calculate with tr. I'm not sure whether or not all 4 of these variants are needed? Or why atmac is in an array. But I figured that "final mac" was the most important.
Anyway another idea for you...
Update: I just noticed the /o in your regex code. Modern Perl doesn't need this hint. I remember bench marking a lot of stuff years ago with Perl 5.10, and I didn't see any difference. Also see Perl regex documentation 5.22, " o - pretend to optimize your code, but actually introduce bugs". I would pay attention to a cautionary note like that!#!/usr/bin/perl use warnings; use strict; my $mac = '28:8a:1c:59:cc:85'; (my $finalmac = $mac) =~ s/(\w+):(\w+)(:?)/$1$2./g; $finalmac =~ s/.$//; #ditch "." at end (my $atmac = $mac) =~ tr/:/ /; print "mac = $mac\n"; print "atmac = $atmac\n"; print "final mac = $finalmac\n"; __END__ mac = 28:8a:1c:59:cc:85 atmac = 28 8a 1c 59 cc 85 final mac = 288a.1c59.cc85
|
|---|
| Replies are listed 'Best First'. |
|---|