in reply to Re: Weird mod_perl Regex '0' behavior.
in thread Weird mod_perl Regex '0' behavior.

I have tried all the suggestions with no luck.

I have gone so far as to hard code this in, just to help figure out what is going on...
my $zero = "0"; if ( $zero eq "0" ) { do_something(); } else { do_something_else(); }
And it failed!

I have two potential explanations.
1. Somehow it is automatically evaluating any "0" string to false, which makes no sense to me.
2. It is treating the input of "0" as an int, and not as a string, which also makes no sense to me.

It couldn't even be some bug with the compiler, because I compile the same code as command line only and have no problems.

Stumped and frustrated.

Replies are listed 'Best First'.
Re^3: Weird mod_perl Regex '0' behavior.
by perrin (Chancellor) on Sep 25, 2008 at 17:25 UTC
    Slow down. What you're saying here doesn't make any sense, so I think you must be missing something larger. Remeber, mod_perl doesn't change anything about perl except the life cycle of your program, so this code has to match the first if condition. Something else (configuration? other code before this? the do_something function?) is preventing you from seeing it. Or maybe this is not the real code you're running, in which case we can't help you if you don't show us the real code.
      Perrin, you are right. I got clogged down in the if that I was showing you that I didn't consider the calling method.

      There was nothing wrong with the code that I put in before, the problem was that the method containing that code, is_input_valid, was called within a conditional that didn't check if it was defined, and eval'd '0' as false. ie.
      unless ( is_input_valid() ) { report_bad_input(); }
      And the proper code should have been,
      unless ( defined is_input_valid() ) { report_bad_input(); }
      Very careless of me. I apologize. Thank you for the help.
        Good. You know, is_bad_input sounds like it's just going to return 1 or 0, so if you intend to have it return the input I'd name it something like clean_input.