Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Simple Perl/CGI Question

Options
  • 30-07-2001 3:48pm
    #1
    Registered Users Posts: 1,202 ✭✭✭


         if($rent_parse2 eq " ")
         {
            $stupid_2=$stupid-10;
            $stupid_2=$stupid_2+$count2;
            $whatout = substr($FORM{'comment'}, $count, $stupid_2);
            $count2=10;
         }
    

    Im only learning perl a bit, and while thats crude enough in its self, Just one thing I need to know is this:

    this line
    if($rent_parse2 eq " ")

    Does not catch it, is there some sort of function or something that I should replace " " with?

    Thanks

    RentZ



Comments

  • Closed Accounts Posts: 577 ✭✭✭Chubby


    The code looks correct if you are comparing the string variable $rent_parse2 to a white space.

    Try this to confirm the comparison to space works.
    $huh = " ";
    if($huh eq " "){
    print "huh\n"
    }

    So only conclusion is what $rent_parse2 doesn't have the value " " (a space) when the code reaches the if statement. Put the following line before it reaches the if statement to see what value it has.

    print $rent_parse2

    [This message has been edited by Chubby (edited 30-07-2001).]


  • Registered Users Posts: 2,660 ✭✭✭Baz_


    What are you trying to do witht that code mate???


  • Registered Users Posts: 4,676 ✭✭✭Gavin


    Perchance try

    if("$rent_parse2" eq " ")

    Include the quotes around the variable. If it's just a blank variable you are looking for, then perl will default that to a boolean false .. i think.

    ie,

    if($rent_parse)
    {
    print "true, text in the variable" ;
    }

    Gav


    Gav


  • Closed Accounts Posts: 4 -gAuD-


    what are you trying to do ??

    what are you testing for ?? whitespace ?? empty string ?? undef ??

    Are you sure the value of the string $rent_parse2 is what you think it is ??



Advertisement