TechMynd, Fresh Downloads and Latest Technology News, Stuff That Works | Downloads, Tips & Tricks, Softwares, Programming, Resources, IT, Computer, Resources, Freewares

Using Variables in CGI



This is an example of simple cgi variable usage.

#!/usr/bin/perl -w
use strict;
use CGI;
my $q = CGI::Vars();
print “Content-Type: text/plain\n\n”;
print “\n”;
print “Versions:\n=================\n”;
print “perl: $]\n”;
print “CGI: $CGI::VERSION\n”;
print “\n”;
print “CGI Values:\n=================\n”;
for my $k (sort keys %$q) {
print “$k [$q->{$k}]\n”;
}
print “\n”;
print “Environment Variables:\n=================\n”;
for my $k (sort keys %ENV) {
print “$k [$ENV{$k}]\n”;
}
print “\n”;

Second Example

#!/usr/bin/perl -wt
use CGI qw(:standard);
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
use strict;
my $email = “someone\@server.com”;
my $url = “http://www.someurl.com”;
print header;
print start_html(”Scalars”);
print <<EndHTML;
<h2>Hello</h2><p>My e-mail address is $email, and my web url is
<a href=”$url” mce_href=”$url”>$url</a>.</p>
EndHTML
print end_html;

Download CGI variables Script

Tags:
Posted in: CGI
Post's RSS » RSS 2.0
Post's Comments RSS » RSS 2.0

Related Posts


Post a Comment

Comment will appear here after approval, Thanks for patience

  Subscribe Via RSS
  Subscribe Via Email

Add to Technorati Favorites

Donate towards TechMynd web hosting Bill!