Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: accessing an anonymous array

by leszekdubiel (Scribe)
on Apr 12, 2020 at 07:50 UTC ( [id://11115398]=note: print w/replies, xml ) Need Help??


in reply to accessing an anonymous array

#!/usr/bin/perl -CSDA use utf8; use Modern::Perl; no warnings qw{uninitialized}; use Data::Dumper; my $tables = { # hash ref "{", keys are day numbers 0 => { # day0 confirmed => [1, 0.334638642561918, 2, 0.8733077785172 +49, 0.8539438, 57158699], deaths => [], }, 1 => { # day1 confirmed => [2, 0.334538642561918, 2, 0.8733077785172 +49, 0.8539438, 57158699], deaths => [], }, 2 => { confirmed => [3, 0.334638442561918, 2, 0.8733077785172 +49, 0.8539438, 57158699], deaths => [], }, }; $$tables{3}{confirmed} = [3, 0.18, 2, 0.849, 0.8, 59]; $$tables{3}{deats} = [2, 3, 4]; $$tables{4} = { confirmed => [4, 1.3, 2, 1.9, 2, 57], deaths => [], }; $$tables{1}{deats}[3] = "three"; $$tables{1}{deats}[5] = "five"; $$tables{5}{alfa} = ["a", "l", "faaaaa"]; for my $d (keys %$tables) { print "\nnext day... $d\n"; for my $t (keys %{$$tables{$d}}) { print "day is $d, table is \"$t\", content: ", (join " +, ", @{$$tables{$d}{$t}}), "\n"; } } print "Dumper is: ", Dumper($tables);

result:

next day... 4 day is 4, table is "confirmed", content: 4, 1.3, 2, 1.9, 2, 57 day is 4, table is "deaths", content: next day... 0 day is 0, table is "confirmed", content: 1, 0.334638642561918, 2, 0.87 +3307778517249, 0.8539438, 57158699 day is 0, table is "deaths", content: next day... 2 day is 2, table is "confirmed", content: 3, 0.334638442561918, 2, 0.87 +3307778517249, 0.8539438, 57158699 day is 2, table is "deaths", content: next day... 1 day is 1, table is "deats", content: , , , three, , five day is 1, table is "confirmed", content: 2, 0.334538642561918, 2, 0.87 +3307778517249, 0.8539438, 57158699 day is 1, table is "deaths", content: next day... 5 day is 5, table is "alfa", content: a, l, faaaaa next day... 3 day is 3, table is "deats", content: 2, 3, 4 day is 3, table is "confirmed", content: 3, 0.18, 2, 0.849, 0.8, 59 Dumper is: $VAR1 = { '4' => { 'confirmed' => [ 4, '1.3', 2, '1.9', 2, 57 ], 'deaths' => [] }, '0' => { 'confirmed' => [ 1, '0.334638642561918', 2, '0.873307778517249', '0.8539438', 57158699 ], 'deaths' => [] }, '2' => { 'confirmed' => [ 3, '0.334638442561918', 2, '0.873307778517249', '0.8539438', 57158699 ], 'deaths' => [] }, '1' => { 'deats' => [ undef, undef, undef, 'three', undef, 'five' ], 'confirmed' => [ 2, '0.334538642561918', 2, '0.873307778517249', '0.8539438', 57158699 ], 'deaths' => [] }, '5' => { 'alfa' => [ 'a', 'l', 'faaaaa' ] }, '3' => { 'deats' => [ 2, 3, 4 ], 'confirmed' => [ 3, '0.18', 2, '0.849', '0.8', 59 ] } };

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (8)
As of 2024-03-28 11:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found