Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Adding a new key-value pair to a nested anonymous hash

by tybalt89 (Monsignor)
on Jan 16, 2025 at 02:43 UTC ( [id://11163709]=note: print w/replies, xml ) Need Help??


in reply to Adding a new key-value pair to a nested anonymous hash

#!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11163708 use warnings; $SIG{__WARN__} = sub { die @_ }; my @lecshun; my $barename = 'a barename'; my $gem = 'ruby'; my $dexi = 0; push @lecshun, [$barename , {package=>$gem, index=>$dexi}]; use Data::Dump 'dd'; dd 'before', \@lecshun; $lecshun[$dexi][1]{newkey} = 'newvalue'; use Data::Dump 'dd'; dd 'after', \@lecshun;

Outputs:

("before", [["a barename", { index => 0, package => "ruby" }]]) ( "after", [ [ "a barename", { index => 0, newkey => "newvalue", package => "ruby" }, ], ], )

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (2)
As of 2025-11-06 20:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your view on AI coding assistants?





    Results (65 votes). Check out past polls.

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.