in reply to Re^8: How can I set a bit to 0 ?
in thread How can I set a bit to 0 ?

> You seem to assume that he's using constants

Question: is there any other strict explanation for barewords as operands?

I've seen this pattern so many times with modules exporting flags and IIRC even perldocs°, that this discussion is surprising me.

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

update

°) see last paragraph in chmod

Replies are listed 'Best First'.
Re^10: How can I set a bit to 0 ?
by hippo (Archbishop) on May 27, 2022 at 14:18 UTC
    Question: is there any other strict explanation for barewords as operands?

    Sure, any subs will do - they don't have to be constants:

    #!/usr/bin/env perl use strict; use warnings; sub upload () { rand 50 } sub getTicket () { rand 60 } sub downLoading () { rand 70 } sub printCLine { print shift } # Start of bartender1382 code my $stats = 0; $stats = upload | getTicket | downLoading; printCLine ($stats); # End of bartender1382 code

    🦛

      > Sure, any subs will do - they don't have to be constants:

      you mean any sub with empty prototype which is the way how constants are implemented in constant

      see https://perldoc.perl.org/perlsub#Constant-Functions °

      and the OP's code still compiles even if your return values are not constant.

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

      °) NB:

        sub FLAG_MASK () { FLAG_FOO | FLAG_BAR } sub FOO_SET () { 1 if FLAG_MASK & FLAG_FOO }
        and the OP's code still compiles even if your return values are not constant.

        Yes, that's entirely my point. :-)


        🦛