So I'm having a bit of a problem with a CGI script. It runs fine, except for the little problem that param(x) doesn't work at all. It will either crash the program or return an undefined value.

use warnings;
use CGI qw(:standard );

$class=chomp ($temp);

$type=chomp ($temp);

$first=chomp ($temp);

$last=chomp ($temp);





open (PER, ">../data/USERS/$type/$first.$last.dat");
print (PER "$first $last\n$class\n$num\n$carrier");
close (PER);
print ("Content-Type:text/html\n\n");
print "<html><body>";
print '<h4>Thank you. Please email the Administrator at <a href="mailto:apcsci@gmail.com">xxxx@gmail.com</a> with any questions or comments</h4>';
print "</body></html>";


10 Years
Discussion Span
Last Post by KevinADC

start with a simple script. Use a form with one text field: 'test'.

use warnings;
use strict;
use CGI qw(:standard);
print header;
print start_html; 
print param('test');
print end_html;

if that still crashes then your install of perl is bad or is maybe a non standard distribution.


somehow theres a problem in the

$class=chomp ($temp);

part, and not regarding the param('x'); call. the simple form worked fine, and i modified my script so that it doesn't convert to uppercase or chomp, and now it's working

EDIT: Well now I feel really stupid. $first=chomp($temp); would return the number of spaces removed, not the string after the spaces had been removed. Oops haha


ahh...my bad, I also missed that. You should not assign a return value from the chomp function, it should just be:

$var = "some value\n";

Note: chomp() only removes the input record seperator from the end of a line or string, which is generally a newline, it does not remove spaces.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.