in reply to Re: Pack uneven length hex
in thread Pack uneven length hex

A faster way to calculate

length($_) % 2

is to do this:

length($_) & 1

Gives the same result, but it's often a bit faster, because the former forces the processor to perform a division, whereas the second one is a simple bitwise AND. We grab the last bit, and that's all.

Replies are listed 'Best First'.
Re^3: Pack uneven length hex
by bliako (Abbot) on Nov 24, 2018 at 13:11 UTC

    thanks! .oO( all the divisions I have caused... )