Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^10: How can I set a bit to 0 ?

by hippo (Bishop)
on May 27, 2022 at 14:18 UTC ( [id://11144227]=note: print w/replies, xml ) Need Help??


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. :-)


      🦛

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11144227]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2024-04-23 06:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found