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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form Help

Status
Not open for further replies.

Needalittlehelp

Technical User
Joined
Apr 20, 2004
Messages
2
Location
US
My form isn't working and I get the error:" 1 Bareword "CGI::parse_form_data" not allowed while "strict subs" in use line 18. "

Can anyone see how to fix it?

Thanks so much!

Code:
#!/usr/local/bin/perl

use strict;

# Let's have some fun my'ing things, shall me?
my $query;
my %form;
my $sendmail;
my $webmaster;
my $thanks;

use CGI;

$query = new CGI;

print $query->header;

%form=CGI::parse_form_data;

$sendmail = '/var/qmail/bin/qmail-inject';
$webmaster = 'webmaster@email.com';
$thanks = "Thank you for visiting my website!  Things are always changing so I hope you pop back again!  If you asked any questions, please allow upto 24 hours for a response.\n";
# $signame = 'Aaron Anderson\n';
# $sigurl = '[URL unfurl="true"]www.yourdowmain.com\n";[/URL]

# Mail to Webmaster
open (MAIL, "$sendmail -t") || die "Can't access $sendmail\n";
	print MAIL "To: $webmaster\n";
	print MAIL "From: $form{'usermail'}\n";
	print MAIL "Subject: Insert subject here!\n\n";
	print MAIL "$form{'username'}\n";
	print MAIL "$form{'userweb'}\n";
	print MAIL "$form{'message'}\n";
	print MAIL "Remote IP address: $ENV{'REMOTE_ADDR'}\n";
close (MAIL);

# Mail to User
open (MAIL, "$sendmail -t") || die "Can't access $sendmail\n";
	print MAIL "To: $form{'$usermail'}\n";
	print MAIL "From: $form{'$weburl'}\n";
	print MAIL "Subject: Thank you for signing my form!\n\n";
	print MAIL "$thanks\n";
	print MAIL "You said:\n";
	print MAIL "$form{'message'}\n";
close (MAIL);

print $query->redirect(-uri=>"[URL unfurl="true"]http://www.somewhere.com/");[/URL]
 
Hi needalittlehelp,

I got this from the perl black book:

Sometimes in Perl, the quotation marks around words are optional if those words can't be interpreted in any other way. For example, the following is clearly a string assignment to the variable $text, so you don't need the quotation marks:

$text = Hello;

Single-word text strings without quotation marks like this are called barewords. If you need to use more than one word, it's not a bareword anymore, and it won't work:

$text = Hello there; # No good
print $text; # Doesn't work

You can use barewords as hash keys if the barewords are only one word long; otherwise, you need the quotation marks.

With "use strict;" you cannot use barewords. Try putting the hash in quotes like:

%form="CGI::parse_form_data";

Leland F. Jackson, CPA
Software - Master (TM)
Nothing Runs Like the Fox
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top