in reply to Perl Switch Errors on certain version

Take a look at perldoc Switch, it says 'Due to the heuristic nature of Switch.pm's source parsing, the presence of regexes specified with raw "?...?" delimiters may cause mysterious errors. The workaround is to use "m?...?" instead.', You have a few of these matches in your code, for example

elsif($new =~ /9/){$action = "Reject";if($debug){&writelog(3,"DEBUG: A +ction=$action");}}

, I'd suggest you stick an "m" in front of that match and see whether that fixes the error.

In general, read the caveats at the end of the perldoc carefully, Switch suffers from problems inherent in source filters, I would not use it in production code (and the original author does not recommend doing so either).


Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it. -- Brian W. Kernighan

Replies are listed 'Best First'.
Re^2: Perl Switch Errors on certain version
by Perl Mouse (Chaplain) on Nov 29, 2005 at 11:13 UTC
    Take a look at perldoc Switch, it says 'Due to the heuristic nature of Switch.pm's source parsing, the presence of regexes specified with raw "?...?" delimiters may cause mysterious errors. The workaround is to use "m?...?" instead.', You have a few of these matches in your code, for example
    elsif($new =~ /9/){$action = "Reject";if($debug){&writelog(3,"DEBUG: A +ction=$action");}}
    Eh, I can't find any question marks in the code you quote. Perhaps you meant to quote some other code? Although I can't find any ?...? constructs in the code of the OP.
    Perl --((8:>*

      I believe the perldoc refers to the practice of using "/.../" for a match instead of "m/.../", regardless of the actual delimiting character used.


      Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it. -- Brian W. Kernighan
        I don't think so. If the manual had meant "/.../", it would have written "/.../". I think the manual page says "?...?" because it means "?...?". Why do you think the manual page would use a rarely used construct, if it meant an often used one?
        Perl --((8:>*