Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: adding value to hash

by shmem (Chancellor)
on Sep 05, 2019 at 13:17 UTC ( #11105659=note: print w/replies, xml ) Need Help??


in reply to adding value to hash

and this works

No, this not works:

my $data = {key => "THIS: "}; my $val = "HI THIS WORKS"; $data{key} .= $val; print "$data{key}"; __END__ HI THIS WORKS

Why? cuz $data (SCALAR, may hold an anonymous hash) and %data (HASH) are different variables.

Read the perldata manual page. Seriously:

Read perldata.

update:

Reading perldata is not a waste of time. It saves you a lot of puzzling and doubts for time to come. Not reading it in turn wastes your and our time.

perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2020-05-27 04:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If programming languages were movie genres, Perl would be:















    Results (152 votes). Check out past polls.

    Notices?