#!/usr/bin/perl -T use strict; use warnings; use CGI qw(:standard); my @name = qw( author distributor copyright abstract keywords description distribution robots language rating ); print header, start_html('Meta Tag Generator'), start_form, table( # i know maps are scarey, just think of this as a # backwards for loop (read bottom up) map { Tr( td(ucfirst $_ . ': '), td(textfield(-name=>$_,-size=>40)), ) } @name ), submit('submit'), end_form, ; if (param('submit')) { for (@name) { # this is how you trim down fetching params code ;) my $param = param($_); # this skips empty fields, you might want to err instead next unless $param; # notice the use of meta() as well as escapeHTML() # since we have alread loaded CGI.pm, let's use it! print escapeHTML(meta{name=>$_,content=>$param}),br; } } print end_html; #### my @dist = qw(local global); my @robo = qw(index noindex follow nofollow); my @lang = qw(EN EN-GB EN-US ES ES-ES FR IT JA KO DE­); my @rate = qw(kids general mature restricted); my %name = ( author => [ sub{textfield(@_)} , {-size=>40} ], distributor => [ sub{textfield(@_)} , {-size=>40} ], copyright => [ sub{textfield(@_)} , {-size=>40} ], abstract => [ sub{textfield(@_)} , {-size=>40} ], keywords => [ sub{textarea(@_)} , {-rows=>5,-columns=>30} ], description => [ sub{textfield(@_)} , {-rows=>5,-columns=>30} ], distribution => [ sub{popup_menu(@_)} , {-values=>['',@dist]} ], robots => [ sub{popup_menu(@_)} , {-values=>['',@robo]} ], language => [ sub{popup_menu(@_)} , {-values=>['',@lang]} ], rating => [ sub{popup_menu(@_)} , {-values=>['',@rate]} ], ); print header, start_html('Meta Tag Generator'), start_form, table( map { Tr( td(ucfirst $_ . ': '), td $name{$_}[0]->( -name=>$_, %{$name{$_}[1]} ) ) } keys %name ), submit('submit'), end_form, ; if (param('submit')) { for (keys %name) { my $param = param($_); next unless $param; print escapeHTML(meta{name=>$_,content=>$param}),br; } } print end_html;