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 ... hmm, that's OK.
No, create a function with the 2 optional parts as input and the string $pack_template as output.
  • Comment on Re^3: Factoring out common code in two methods of a class

Replies are listed 'Best First'.
Re^4: Factoring out common code in two methods of a class
by BrowserUk (Patriarch) on Aug 05, 2009 at 20:59 UTC
    No, create a function with the 2 optional parts as input and the string $pack_template as output.

    What!? What possible merit is there is creating a function to do concatenation? Perl has an operator to do that:

    my $packed = pack PACK_TEMPLATE . (condition ? OPTIONAL_ADDITION : '' +), @bits;

    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.