#!/usr/local/bin/perl -wT
use strict;
use CGI qw/:standard/;
# Geturl.pl
# A little Perl script to read, decode and print the names
# and values passed to it from an HTML Form thru CGI.
# Get the HTML header, ender, define the page title.
my $Title = "Get Information From a URL";
print header(),
start_html ( -title => $Title ),
h1( $Title ),
hr();
# This gets the name of all of the form elements
my @names = param();
# The param() function takes the name of the parameter and returns its value
foreach my $name ( @names ) {
print "Name = $name, Value = " . param( $name ) . "
\n";
}
print end_html;
####
color=red&color=blue&color=some%20other%20value
####
foreach my $name ( @names ) {
my @values = param( $name );
print "Name = $name, Value(s) = " , join (',' @values) , "
\n";
}
####
# Assign param() to a scalar and you only get the first value
my $value = param( $name );
# Assign param() to an array and you get all of the values
my @values = param( $name );