Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Getting feet wet with hashes

by arturo (Vicar)
on Oct 11, 2001 at 21:55 UTC ( [id://118281]=note: print w/replies, xml ) Need Help??


in reply to Getting feet wet with hashes

Your syntax is incorrect, but you have the basic idea. %hash refers to the hash, $hash{$key} refers to the value contained in %hash that's associated to $key (the value is a scalar, so think of $ as referring to scalars and you'll have it. I don't know whether $key=>i++, does what you want it to (even with the correction) but assuming i is a variable, you need to add the $ to the front of it.

Note also that hash keys occur inside curly braces {}. Final note: perl doesn't support C-style comments -- # marks the rest of a line as a comment.

hth!

perl -e 'print "How sweet does a rose smell? "; chomp ($n = <STDIN>); +$rose = "smells sweet to degree $n"; *other_name = *rose; print "$oth +er_name\n"'

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2024-04-20 02:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found