Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Braces around a section of code

by Athanasius (Archbishop)
on Jun 26, 2019 at 13:30 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11101938]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2024-03-28 12:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found