in reply to Re: Help ! New in perl and cgi
in thread Help ! New in perl and cgi

Hi Marza, I tried your code and it did not work but if i replace eq with =~
if ($comment1 =~ " ") { $comment1 = "n/a"; } if ($comment2 =~ " ") { $comment2 = "n/a"; }
Then it run but all of the comeent1 and comment2 are n/a . Do you know why ? Thanks for reading

Replies are listed 'Best First'.
Re: Re: Re: Help ! New in perl and cgi
by abstracts (Hermit) on May 22, 2002 at 06:00 UTC
    if ($comment1 =~ " ") { # reads: if comment1 *HAS* a space ... } if ($comment1 !~ " ") { # reads: if comment1 *DOESN'T HAVE* a space ... } if ($comment1 eq " ") { # reads: if comment1 *IS* a space ... } if ($comment1 ne " ") { # reads: if comment1 *IS NOT* a space ... } if ($comment1 == " ") { # reads: if comment1 *Numerically Equals* a sp +ace # since space == 0, # ==> same as # if($comment1 == 0){ ... } ... } if ($comment1 != " ") { # reads: *Numerical* not equal to... ... }
    Hope this helps,,,

    PS: As Marza suggested, the llama book is a good book.

    Update: Added the other cases.