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

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

🦛

Replies are listed 'Best First'.
Re^11: How can I set a bit to 0 ?
by LanX (Saint) on May 27, 2022 at 14:26 UTC
    > 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. :-)


      🦛