# Read in URL file query and untaint # one or more word characters if ($query = param('page') =~ /(\w+)/) { $urlist = $1; } else {die "Please request pages by alphanumeric name only. You might find what you're looking for by starting at site home of http://host.dom/index.pl?page=home\n"; } # Build array of urlist files # Confirm that supplied param is valid file opendir DIR, "$confdir/"; my @files = grep { $_ ne '.' && $_ ne '..' && } readdir DIR; closedir DIR; unless (grep{$_ eq $urlist} @files) { die "You requested a page that does not exist. You might find what you're looking for by starting at site home of http://host.dom/index.pl?page=home\n"; } # read lists of page URLs from external file # loop through lists, parsing for HTML::Template use unless (my $return = do "$confdir/$urlist") { die "Cannot parse $urlist: $@" if $@; die "Cannot do $urlist: $!" unless defined $return; die "Cannot run $urlist" unless $return; } for (my $i = 0; $i < $#url_array; $i+=2) { my($loop, $aref) = @url_array[$i, $i+1]; my @vars; for (my $j = 0; $j < $#{$aref}; $j+=2) { my($name, $url) = @{$aref}[$j, $j+1]; push @vars, { name => $name, url => $url }; } $template->param($loop, [ @vars ]); }