in reply to Generating HTML from a Hashref of Hashrefs

I think you're better off using a Templating engine. For example to create a htmlfile filled by a perl data structure using the fabulous Template-Toolkit:

script:
use strict; use warnings; use Template; #you would normally take this from a file my $template = join "", <DATA>; #some sample data my %data = ( title => "My Albums", albums => [ { artist=>"Some Musician", songs=> [ "Some Song", "Some Other Song", ] }, { artist=>"DocMarten", songs=> [ "The Doc goes wild", "Heavy Shoes", ] } ] ); #create template object and execute template my $tt = Template->new(); $tt->process (\$template, \%data, "myfile.html"); __DATA__ <html> <head> <title>[% title %]</title> </head> <body> [% FOR album = albums %] <h1>[% album.artist %]</h1> [% FOR song = album.songs %] <h2>[% song %]<h2> [% END %] [% END %] </body>

Output (myfile.html):
<html> <head> <title>My Albums</title> </head> <body> <h1>Some Musician</h1> <h2>Some Song<h2> <h2>Some Other Song<h2> <h1>DocMarten</h1> <h2>The Doc goes wild<h2> <h2>Heavy Shoes<h2> </body>


holli, /regexed monk/

Replies are listed 'Best First'.
Re^2: Generating HTML from a Hashref of Hashrefs
by rje (Deacon) on Oct 07, 2005 at 20:54 UTC
    As a matter of fact, I was planning on using Text::Template. However, TTT (The Template Toolkit) has quite a bit of oomf behind it, what with that "for X = foo.bar" metaphor...