Come for the quick hacks, stay for the epiphanies. | |
PerlMonks |
Re: Help me decipher code containing map functionby BrowserUk (Patriarch) |
on May 20, 2017 at 03:35 UTC ( [id://1190694]=note: print w/replies, xml ) | Need Help?? |
I thought that the map function takes in a list(perhaps an array), I do not see the above code having a list passed to it. unpack outputs a list. In this case it extracts a list of 6 numbers (ascii values) from the (first) 6 bytes in $octetstr. It then uses map to iterate over those 6 numbers converting them to 2-digit hex strings and appending them to $val Before spliting them (the 2-digit hex strings) back apart and then joining them again interspersed with ':'s. It is an altogether overcomplicated and clumsy piece of code. The whole process can be done with just $mac = join ':', unpack '(H2)*', $octetstr; Ie. Given:
Instead of:
You could just do:
With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority". The enemy of (IT) success is complexity.
In the absence of evidence, opinion is indistinguishable from prejudice.
Suck that fhit
In Section
Seekers of Perl Wisdom
|
|