in reply to Re^2: Factoring out common code in two methods of a class
in thread Factoring out common code in two methods of a class

I guess I'll have to leave off the last two parts which in this application are optional, and add them to PACK_TEMPLATE programatically after the length field

Personally, I'd just create 2 or 3 constants and select between them at runtime:

use constant T1 = '...'; use constant T2 = t1 . '...'; use constant T3 = T1 . '...'; # or use constant T3 = T2 . '...'; ... my $packed = pack ( T1, T2, T3 )[ condition() ], @bits;

Wher condition() returns an integer 0 .. 2.


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".
In the absence of evidence, opinion is indistinguishable from prejudice.
RIP PCW