This will create two new files "Filename1.html" and "Filename2.html".use Template; my $template = Template->new; my $tmpl = 'table.tmpl'; my %names; while ( my $line = <DATA> ) { chomp $line; my ($name,$item,$answer) = ($line =~ m/^(\w+)\s+(\w+)\s*-\s*(.*)/) +; push( @{ $names{$name} }, { item=>$item, answer=>$answer } ); } for my $name ( keys %names ) { my $table = { title=>$name, rows=>$names{$name} }; $template->process( $tmpl, $table, "$name.html" ) || die $template->error(); } __DATA__ Filename1 Item1 - Answer Filename1 Item2 - Answer Filename2 Item1 - Answer Filename2 Item2 - Answer
Obviously, you need to add the html and body tags around this, and you can also add CSS and other static elements.<h1>[% title %]</h1> <table> [% FOREACH row IN rows %] <tr> <td>[% row.item %]</td> <td>[% row.answer %]</td> </tr> [% END %] </table>
In reply to Re: How to ignore and retrieve certain values from text file which is to be split into multiple HTML files with tables?
by tangent
in thread How to ignore and retrieve certain values from text file which is to be split into multiple HTML files with tables?
by perly_white
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |