UBB.Dev
Posted By: Chuck1616 Undef, If, and a couple others - 07/30/2001 1:33 AM
Say I have this code, test.cgi:

#!/usr/bin/perl

print "Content-type:text/htmlnn";

undef ($test);

if ($test eq 'test') {
print 'Did It Work';
}

If I were to type http://www.myserver.com/cgi-bin/test.cgi?test=test

Shouldn't it print "Did It Work" on my screen?

For me all it does is print a blank screen. What am I doing wrong?
Posted By: Mark Badolato Re: Undef, If, and a couple others - 07/30/2001 2:09 AM
no it shouldn't.

1) you didn't do anything to get the query string
2) you undef right before checking the value, which would negate anything you stored in $test from the query string if you HAD parsed the query string

#!/usr/bin/perl

use strict;
use CGI qw/:standard/;

my $test = param('test');

print 'Did it work?' if $test eq 'test';
© UBB.Developers