Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Braces around a section of code

by Athanasius (Bishop)
on Jun 26, 2019 at 13:30 UTC ( #11101938=note: print w/replies, xml ) Need Help??


in reply to Braces around a section of code

Hello thnksnw, and welcome to the Monastery!

Braces create a block, which has its own lexical scope. So you might do something like this:

{ my $foo = 42; # do more with $foo here } # $foo is no longer in scope here

to restrict the scope of $foo to only that part of the code where it ought to be used.

In the code shown, I can’t see any advantage to the braces. Is this the real code? If so, maybe the author was intending to add an if above it to remove the code from execution or even from compilation. For example,

use constant DEBUG => 0; ... if (DEBUG) { # This code will not be compiled }

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (9)
As of 2020-06-01 16:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you really want to know if there is extraterrestrial life?



    Results (5 votes). Check out past polls.

    Notices?