Intrepid has asked for the wisdom of the Perl Monks concerning the following question:
I'm looking for help understanding dereferencing with a complex data structure. I have an array of references to anonymous arrays which in turn contain a scalar as a the first item and a reference to an anonymous hash as the second item:
push @lecshun, [$barename , {package=>$gem, index=>$dexi}];
For some items in the array I want to add another key-value pair to the hash, but I just cannot figure out how to do that. I have only gotten so far:
$lecshun[$dexi - 1] ##? <<-- what to do here ?## = inv($gem);
The subroutine inv is this, although it could be anything:
sub inv { my $pkg = $_[0]; my @pki = qx{cygcheck -i --inst $pkg}; for my $ln (@pki) { next unless $ln=~/^Version\s+:\s(\S+)/; say "Pkg ".$1; return (datum => $1); } }
Maybe I am making this too complicated for myself.
Jan 16, 2025 at 02:07 UTCA just machine to make big decisions
Programmed by fellows (and gals) with compassion and vision
We'll be clean when their work is done
We'll be eternally free yes, and eternally young
Donald Fagen -> I.G.Y.
(Slightly modified for inclusiveness)
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Adding a new key-value pair to a nested anonymous hash
by tybalt89 (Monsignor) on Jan 16, 2025 at 02:43 UTC | |
Re: Adding a new key-value pair to a nested anonymous hash
by Marshall (Canon) on Jan 16, 2025 at 03:03 UTC | |
Re: Adding a new key-value pair to a nested anonymous hash
by Intrepid (Curate) on Jan 17, 2025 at 03:00 UTC | |
by Danny (Chaplain) on Jan 17, 2025 at 16:16 UTC | |
Re: Adding a new key-value pair to a nested anonymous hash
by BillKSmith (Monsignor) on Jan 17, 2025 at 21:02 UTC |