Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Perl CGI - Parsing a HTML form

Status
Not open for further replies.

carlosAlberto

IS-IT--Management
Oct 9, 2001
109
0
0
GB
Hi all,

I'm using the cgi-lib.pl file to parse the data submitted from my HTML form.

The variables returned are $input{'nameOfFormItem'}

The dilemma i face is:

the posted data will only return -
$input{'mibOid'} OR $input{'mib'}

I would like to test which one does actually hold a value. I tried:
if ($input{'mibOid'} eq "") and if (!$input{'mibOid'})
but both don't work.


Any ideas??????


Carl.
 
You're close, but to test if a variable holds a value you could do it one of two ways (there are probably more, but this is how I've been taught)

if ($input{'username'}) {
print "$input{'username') had a value!\n";
}

or

if ($input{'username'} ne "") {
print "$input{'username') had a value!\n";
}

Hope this helps!

sulfericacid
You were trying to set the value to eq "" which would remove all variable contents before you even know it held anything.

Hope this helps@ "Age is nothing more than an inaccurate number bestowed upon each of us at birth as just another means for others to judge and classify us- sulfericacid
 
You were trying to set the value to eq "" which would remove all variable contents before you even know it held anything.

[tt]eq[/tt] is a string equality operator, not an assignment operator. The test [tt]($input{'mibOid'} eq "")[/tt] is testing to see if the value in the [tt]%input[/tt] hash with the key [tt]mibOid[/tt] is an empty string.

My guess is that it is, in fact, undefined.

You might want to try changing that test to:[tt]if (exists $input{'mibOid'})[/tt] which checks to see if there is any value assigned to that key.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top