Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Variable with curly braces? (updated)

by AnomalousMonk (Archbishop)
on Oct 24, 2021 at 08:24 UTC ( [id://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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (3)
As of 2024-03-29 04:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found