Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: hash to differentiate type and tokens

by sundialsvc4 (Abbot)
on Jul 14, 2011 at 01:14 UTC ( #914266=note: print w/replies, xml ) Need Help??


in reply to hash to differentiate type and tokens

Perl has a few “tricks up its sleeve” to make some coding tasks a little easier.   For example, if you simply write, $somehash{'foo'}++, then the key associated with 'foo' will be an integer that gets incremented ... even if no such key exists previously!   Perl simply “does what you mean.”   It automagically creates a key if necessary, then increments it.   So, if you want to use a hash to count the number of occurrences of words in a string (a very common objective...)   Perl, by design, makes that trivial.

  • Comment on Re: hash to differentiate type and tokens

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://914266]
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 2023-12-10 10:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your preferred 'use VERSION' for new CPAN modules in 2023?











    Results (39 votes). Check out past polls.

    Notices?