#!c:\perl\bin\perl.exe #=========================================================== # DESCRIPTION: Take data from DBM::Deep for presentation on www page. #=========================================================== use strict; use warnings; use CGI; use HTML::Template; my $CGI = CGI->new(); my $user; my $machine; my $loop_data; my %row_data; my %HoH = ( user1 => { machine1 => { key1 => "value1", key2 => "value2", key3 => "value3" }, machine2 => { key1 => "value4", key2 => "value5", key3 => "value6" }, machine3 => { key1 => "value7", key2 => "value8", key3 => "value9" }, } ); for $user ( keys %HoH ) { for $machine ( sort keys %{ $HoH{$user} } ) { $row_data{MACHINE} = $machine; for my $key ( sort keys %{ $HoH{$user}->{$machine} } ) { $row_data{DATA} = $HoH{$user}->{$machine}->{$key}; push @{$loop_data}, \%row_data; } } } # read the template as a scalar from DATA my $html = do { local $/; }; # prepare the template and substitute the values my $template = HTML::Template->new( scalarref => \$html ); $template->param( THIS_LOOP => $loop_data ); # print the data print $CGI->header(); print $template->output(); __DATA__ Inventory

machines

Machine Key One Key Two Key Three