#!/usr/bin/perl use strict; use warnings; use CGI; use CGI::Carp qw ( warningsToBrowser fatalsToBrowser ); use HTML::Template; my $q = new CGI; my @polls = <*.yaml>; my $polls = []; map {$_ =~ s/(.*)\.yaml$/$1/} @polls; foreach my $poll (@polls) { my %row; $row{poll} = $poll; push @$polls, \%row; } #die join(", ", @polls); print $q->header(); my $template = HTML::Template->new(filename => 'templates/what_poll.tmpl', die_on_bad_params => 1); $template->param( 'polls' => $polls ); print $template->output;