SolHai Haile wrote:
> Hi All,
> I need to read mac address and program into a device:
> Example:
>
> my @mac = "00:14:85:50:A3:CF";
> while (<@mac>)
> {
> my ($oct0,$oct1,$oct2,$oct3,$oct4,$oct5) = split /:/,$_;
>
> }
> 1. How do I convert $oct0..$oct5 to hex
> $oct0 = 0x00, $oct1=0x14, .., $oct5 = 0xcf
> The problem is I need to increment $oct5 by 1 and by 2 to have another
> two mac addresses.
> 2. Is my approch correct?
>
> I appreciate for your help.
Here's the +1 part if I understand your Q :
my $mac = "00:14:85:50:A3:CF";
my @f = split /:/, $mac;
$f[-1] = sprintf "%02X", hex ($f[-1]) + 1;
my $newmac = join ':', @f;
print $newmac, "\n";
Repeat for +2.
_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs