in reply to Re^10: converting binary to decimal
in thread converting binary to decimal

Wait. Are you saying that if someone has "use feature 'bitwise' in their header, then this code fails? How do I make sure it doesnt? Can I write "no feature 'bitwise';" inside binary2decimal() to make sure it doesn't misbehave? Or is that unnecessary?

Replies are listed 'Best First'.
Re^12: converting binary to decimal
by LanX (Saint) on Jun 08, 2025 at 16:02 UTC
    > Wait. Are you saying that if someone has "use feature bitwise in their header, then this code fails?

    If it's in the same scope, yes.

    Not sure what header means for you.

    > Can I write "no feature 'bitwise';" inside binary2decimal() to make sure it doesn't misbehave?

    Theoretically yes, try it out.

    Better use feature bitwise and change the operator to |. ... But this wouldn't work in older Perl.

    So in case backwards compatibility is an issue, maybe no combined with if Version >...

    In general, if someone was copying that code into his scope, you shouldn't be bothered about their fate. It's their responsibility.

    The right approach of sharing code is to use modules, not boilerplating.

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    see Wikisyntax for the Monastery