Help for this page

Select Code to Download


  1. or download this
    my $mac = 'ff:ff:ff:ff:ff:ff';
    if (6 == ($_ = () = $mac =~ /([0-9A-Z]{1,2})(?::|$)/ig) ){ 
        $mac =~ s/([0-9A-Z]{1,2})(?::|$)/ substr "0$1", -2 /ieg;
    }
    
  2. or download this
    my $mac = 'ff:ff:ff:ff:ff:ff';
    $mac =~ s[^ (?: ( [0-9A-Z]{1,2} ) : ){5} ( [0-9A-Z]{1,2} ) $] 
             [ sprintf '%02s' x 6, $1, $2, $3, $4, $5, $6 ]iex;
    
  3. or download this
    my $re_mac = '(?: ( [0-9A-Z]{1,2} ) : )' x 5 . '( [0-9A-Z]{1,2} )';
    $re_mac = qr[$re_mac]ix;
    ....
    
    $mac =~ s[^ $re_mac $] [ sprintf '%02s' x 6, $1, $2, $3, $4, $5, $6 ]e
    +x;