sdani has asked for the wisdom of the Perl Monks concerning the following question:
The output shows that when I print out the reference of the @say variable, that looks alright, but when I try to assign its value, somehow does not work. I'm sure, this problem is due to my bad knowledge of references, but it I could not find the solution elsewhere. Thanks for your guidance!echo -e 'animal dog bark 2\nanimal dog woof 3\nanimal cat meaow 3' | p +erl -MData::Dumper -lane ' ($kind, $name, $say, $count) = @F; $h{$kind}{$name}{$say} = $count; END { foreach $kind (keys %h){ foreach $name (keys %{$h{$kind}}){ @say = keys %{$h{$kind}{$name}}; print Dumper \@say; $b{$name} = \@say; } } print Dumper %b }'
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Reference madness
by choroba (Cardinal) on Jul 31, 2017 at 12:06 UTC | |
by sdani (Novice) on Jul 31, 2017 at 12:58 UTC | |
by choroba (Cardinal) on Jul 31, 2017 at 13:32 UTC | |
by Athanasius (Archbishop) on Jul 31, 2017 at 13:39 UTC | |
by LanX (Saint) on Jul 31, 2017 at 14:55 UTC | |
by Anonymous Monk on Jul 31, 2017 at 13:28 UTC | |
|
Re: Reference madness
by LanX (Saint) on Jul 31, 2017 at 12:07 UTC |