Using the => operator.
#!/usr/bin/perl
%weekday = (
'01' => 'Mon',
'02' => 'Tue',
'03' => 'Wed',
'04' => 'Thu',
'05' => 'Fri',
'06' => 'Sat',
'07' => 'Sun',
);
$pointer = \%weekday;
$i = '05';
printf '$$pointer{$i} is ';
printf "$$pointer{$i} \n";
printf '${$pointer}{$i} is ';
printf "${$pointer}{$i} \n";
printf '$pointer->{$i} is ';
printf "$pointer->{$i}\n";
printf '${$pointer{$i}} is ';
printf "${$pointer{$i}} \n";
printf '${$pointer->{$i}} is ';
printf "${$pointer->{$i}}";
Related examples in the same category