Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re: Variable with curly braces? (updated)

by AnomalousMonk (Bishop)
on Oct 24, 2021 at 08:24 UTC ( #11137947=note: print w/replies, xml ) Need Help??

in reply to Variable with curly braces?

Further to Athanasius's reply:

The second method just uses the hash without first declaring it. This will work only if the use strict; pragma is not in effect. This is considered bad style in modern Perl.
wyt248er: The second method works (without strictures) because it will autovivify a named package-global variable of the correct type if it does not already exist. Package-globals are... well, global, and best practice suggests avoiding their use without a good and well-understood reason. See perldata for more examples of the use of hashes. (Update: And see the Perl Data Structures Cookbook for lots more on hash/array structures.)

Give a man a fish:  <%-{-{-{-<

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (7)
As of 2021-12-02 11:18 GMT
Find Nodes?
    Voting Booth?
    R or B?

    Results (18 votes). Check out past polls.