| Category: | Miscellaneus |
| Author/Contact Info | /msg sulfericacid |
| Description: | 10-field meta tag generator. Create flashy meta tags on the fly and give the option to have a copy of the tags emailed to the user. Help! I know this is a very large code with many repetitive lines. I'd like to rewrite this script once more from grounds up to make it smaller but found that is too much work for me to understand right now. Instead can someone show me a way to shrink the my $var = param('name') section? |
#!/usr/bin/perl -w
use CGI::Carp 'fatalsToBrowser';
use strict;
use warnings;
my $adv = "Advertise your script here!"; # Simple text ad for this sc
+ript
my $sendmail = "/usr/lib/sendmail";
my $scriptname = "Meta Tag Generator"; # Name you want to call this
+ script
my $scriptlocation = "http://www.where.com/tags.pl"; # Link send to th
+eir email addy
use CGI qw/:standard/;
print header,
start_html('Meta Tag Generator');
print start_form(), table(
Tr(td( "Email Address: "), td(textfield(-name=>'usermail',
-size=>40)) ),
Tr(td("Author: "), td(textfield(-name=>'author',
-size=>40)) ),
Tr(td("Distributor: "), td(textfield(-name=>'distributor
+',
-size=>40)) ),
Tr(td("Copyright: "), td(textfield(-name=>'copyright',
-size=>40)) ),
Tr(td("Abstract: "), td(textfield(-name=>'abstract',
-size=>40)) ),
Tr(td("Keywords: "), td(textarea(-name=>'keywords',
-rows=>5,
-columns=>30)) ),
Tr(td("Description: "), td(textarea(-name=>'description'
+,
-rows=>5,
-columns=>30)) ),
Tr(td("Robots: "), td(popup_menu(-name=>'robots',
-values=>['','index','noindex','follow','nofollow'])) )
+,
Tr(td("Distribution: "), td(popup_menu(-name=>'distributi
+on',
-values=>['','local','global'])) ),
Tr(td("Language: "), td(popup_menu(-name=>'language',
-values=>['','EN','EN-GB','EN-US','ES','ES-ES','FR','IT
+','JA','KO','DE'])) ),
Tr(td("Rating: "), td(popup_menu(-name=>'rating',
-values=>['','kids','general','mature','restricted']))
+),
Tr(td(), td(checkbox(-name=>'emailme',
-checked=>1,
-value=>'ON',
-label=>'Email my tags!')) ),
Tr(td(), td(submit) ),
),
end_form(),
hr();
my $abstract = param('abstract');
my $usermail = param('usermail');
my $author = param('author');
my $distributor = param('distributor');
my $keywords = param('keywords');
my $description = param('description');
my $distribution = param('distribution');
my $robots = param('robots');
my $rating = param('rating');
my $language = param('language');
my $copyright = param('copyright');
my $emailme = param('emailme');
my $tags ='';
if (param('abstract') ne "") {
$tags .= qq(<meta name="abstract" content="$abstract"><br>)
+;
}
if (param('author') ne "") {
$tags .= qq(<meta name="author" content="$author"><br>);
}
if (param('distributor') ne "") {
$tags .= qq(<meta name="distributor" content="$distributor">
+;<br>);
}
if (param('copyright') ne "") {
$tags .= qq(<meta name="copyright" content="$copyright"><br
+>);
}
if (param('keywords') ne "") {
$tags .= qq(<meta name="keywords" content="$keywords"><br>)
+;
}
if (param('description') ne "") {
$tags .= qq(<meta name="description" content="$description">
+;<br>);
}
$tags .= qq(<meta name="generator" content="$adv"><br>);
if (param('robots') ne "") {
$tags .= qq(<meta name="robots" content="$robots"><br>);
}
if (param('language') ne "") {
$tags .= qq(<meta name="language" content="$language"><br>)
+;
}
if (param('distribution') ne "") {
$tags .= qq(<meta name="distribution" content="$distribution"&
+gt;<br>);
}
if (param('rating') ne "") {
$tags .= qq(<meta name="rating" content="$rating"><br>);
}
if (param()) {
print "<b>Instructions:</b> To install your brand new meta tags copy a
+nd paste your code below between the \<HEAD\> and \</HEAD\> tags of y
+our website!<br><br>";
print $tags;
print hr;
print end_html();
### Sent their tags via email
if ($emailme ne "") {
$tags =~ s/</</g;
$tags =~ s/>/>/g;
$tags =~ s/<br>/\n/g;
open (MAIL, "|$sendmail -t") or die "Cannot access mail";
print MAIL "To: $usermail\n";
print MAIL "From: $adminmail\n";
print MAIL "Subject: Your Meta Tags\n\n";
print MAIL "This is a copy of the meta tags you designed with '$scri
+ptname' recently.\n\n";
print MAIL "To install these please paste these codes inside the HEA
+D tags of your website.\n\n";
print MAIL "$tags\n\n";
print MAIL "To make new meta tags please come back to $scriptlocatio
+n!\n";
close (MAIL);
}
}
|
|
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(jeffa) Re: Meta Tag Generator
by jeffa (Bishop) on Apr 05, 2003 at 21:19 UTC | |
by Aristotle (Chancellor) on Apr 06, 2003 at 01:12 UTC | |
|
•Re: Meta Tag Generator
by merlyn (Sage) on Apr 08, 2003 at 04:53 UTC |