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

Errors in script 1

Status
Not open for further replies.

JimJx

Technical User
Joined
Feb 16, 2001
Messages
202
Location
US
Hi all,

I have been away from PERL for a while (so I am pretty sure I am doing something stupid) and I have a short script:
Code:
#!/usr/bin/perl

use Digest::MD5 qw(md5_hex);
use DB_File;
use CGI qw(standard carp);

read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
print "Content-type: text/html\n\n";
print "<HTML>\n";
print "<BODY>\n";

@pairs = split(/&/, $buffer);

foreach $pair (@pairs) {
      ($name, $value) = split(/=/, $pair);

      $value =~ tr/+/ /;
      $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;

      $FORM{$name} = $value;
      print "$FORM{$name} = $value;\n";
}

print "$FORM{'userName') " + ' : ' + " $FORM{'password')\n";


This is what I am getting in my error log:
Code:
[Tue Aug 22 22:39:06 2006] [error] [client 127.0.0.1] syntax error at /var/[URL unfurl="true"]www/htdocs/cgi-bin/addUser.pl[/URL] line 24, near "'userName') ", referer: [URL unfurl="true"]http://localhost/addNew.html[/URL]
[Tue Aug 22 22:39:06 2006] [error] [client 127.0.0.1] Missing right curly or square bracket at /var/[URL unfurl="true"]www/htdocs/cgi-bin/addUser.pl[/URL] line 24, within string, referer: [URL unfurl="true"]http://localhost/addNew.html[/URL]
[Tue Aug 22 22:39:06 2006] [error] [client 127.0.0.1] Execution of /var/[URL unfurl="true"]www/htdocs/cgi-bin/addUser.pl[/URL] aborted due to compilation errors., referer: [URL unfurl="true"]http://localhost/addNew.html[/URL]
[Tue Aug 22 22:39:06 2006] [error] [client 127.0.0.1] Premature end of script headers: addUser.pl, referer: [URL unfurl="true"]http://localhost/addNew.html[/URL]

At this point alll I want is for the var to print but I can't seem to get it to even do that without giving me a 500.....

Any suggestions are appreciated.
Jim
 
Code:
print "$FORM{'userName') : $FORM{'password')\n";

or you would use the dot '.' for concatenation in perl, not the plus '+' like in javascript(?)

Code:
print "$FORM{'userName') " . ' : ' . " $FORM{'password')\n";
 
Woah. Don't use that code for parsing form data. You're already importing CGI.pm's form parsing functions there. Just do this:
Code:
my $username = param( 'userName' );
Simple!
 
so Ishnid do you not need to do
Code:
my $cgi = new CGI;
my $username = $cgi->param('userName');


"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
Not with this:
Code:
use CGI qw(:standard);
That imports all the standard functions into your script. What you've posted is the object-oriented way of doing it.
 
cool - nice one!

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top