Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Variable with curly braces?

by Bod (Parson)
on Oct 24, 2021 at 22:14 UTC ( [id://11137986]=note: print w/replies, xml ) Need Help??


in reply to Variable with curly braces?

syntax error at ./test.pl line 3, near "$v{u"

The reason the this is a syntax error is that you cannot declare one element of an array or hash with my.

Athanasius has already given you great examples of working code.

To add...Perl has three basic data types: scalars, arrays and hashes:
scalars hold a single value and are of the form $scalar
arrays hold an ordered list of values and are accessed individually as $array[n] where n is the index in the list. They are accessed as a whole list using @array
finally hashes are unordered lists accessed by a key. Individually they are $hash{key} and as a complete hash with %hash.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (9)
As of 2024-04-19 06:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found