Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

returns wrong results. why

returns wrong results. why

returns wrong results. why

here is the entire code.  this procese an input for "operation".  if it is run then it returns run.  if it does not it returns not.  no matter what i pass to it it returns run.  i am new to perl and have no idea.

# get form input, split each form field into @pairs array
                          read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
# clean up each array element
foreach $pair (@pairs) {
   ($name, $value) = split(/=/, $pair);
   $value =~ tr/+/ /;
   $value =~    s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
   $value =~ s/\n/ /g; # replace newlines with spaces
   $value =~ s/\r//g; # remove hard returns
   $value =~ s/\cM//g; # delete ^M's
   $FORM{$name} = $value;

if ($FORM{'operation'}=run){
print <<END;
Content-Type: text/html\n\n
print <<END;
Content-Type: text/html\n\n

RE: returns wrong results. why

The line if ($FORM{'operation'}=run){ looks a little suspect. Easy mistake to make.

When you're comparing two numbers - use ==
When you're comparing two strings - use eq

Don't use = as that is the assignment operator, use that when you want to set the value of something, like this:

$x="hello";                    # $x now equals "hello"
if($x eq "goodbye"){            # this will fail
    print "whoops!!\n";
} else {
    print "it worked!!\n";    # this should print

Oh - and don't forget to put strings in quotes.

Cargill's Corporate Web Site

RE: returns wrong results. why

thanks im used to visual basic which only uses one = and the quotes i just plain forgot.

Karl Pietri

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close