More complex data structures
$grade{Name}{Subject}[index] = Exam-Grade; $grade{Name}{Subject} = Final-Grade;
examples/references/complex_data_structure.pl
#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my %grades; $grades{"Foo Bar"}{Mathematics} = 97; $grades{"Foo Bar"}{Literature} = 67; $grades{"Peti Bar"}{Literature} = 88; $grades{"Peti Bar"}{Mathematics} = 82; $grades{"Peti Bar"}{Art} = 99; $grades{"Foo Bar"}{Chemistry}[0] = 30; $grades{"Foo Bar"}{Chemistry}[1] = 48; $grades{"Foo Bar"}{Chemistry}[2] = 72; $grades{"Foo Bar"}{Chemistry}[3] = 80; print Dumper \%grades;
$VAR1 = { 'Peti Bar' => { 'Art' => 99, 'Literature' => 88, 'Mathematics' => 82 }, 'Foo Bar' => { 'Chemistry' => [ 30, 48, 72, 80 ], 'Literature' => 67, 'Mathematics' => 97 } };