3 ms·
You may use this array to convert a number (in variable $num) from decimal to hex using base conversion formula: Or, you could save yourself the energy and jus
by jrockway 17y ago
You may use this array to convert a number (in variable $num) from decimal to hex using base conversion formula:
Or, you could save yourself the energy and just write "sprintf '%x', $whatever"...
I'm also unsure of the value of treating everything as a one-liner. If your one-liner is "change foo to bar in all files in the directory", that's useful. If it's "find the length of an array", that's not so useful in the one-liner context. So why wrap every example with "perl -le ..."?
(If you want to play with Perl one line at a time, install Devel::REPL.)
- pkrumins 17y agoYes, that's the easiest way to convert. I was illustrating a use of a hex lookup table there. I wrapped most of them in "perl -le ..." so that you can quickly just copy/paste to try them out. I had forgotten about Devel::REPL. I sometimes blended together perl recipes and perl one-liners, that's why I included that print "length of an array."