in reply to Regex: same code works and fails, why?

The debug output suggests that you have read in the entire file at once ($/ being undefined?). Hence, m/^#/ matches (no need for /o here, or the parens), next is performed, but there's no next line, so no equipment to be found.

Abigail

  • Comment on Re: Regex: same code works and fails, why?

Replies are listed 'Best First'.
Re: Re: Regex: same code works and fails, why?
by Hena (Friar) on Jan 07, 2004 at 15:37 UTC
    You're right.
    Huge Thanks.

    I do have in my load function 'local $/;' to use eval on file which is made by Data::Dumper->Dump. And then continue to use 'Equipment::read_player();' without resetting $/ :).

    Shouldn't the /o make it faster (in theory)? Parens i use, because it makes the line more readable for me atleast.
      What makes you think the /o makes it faster? Is there some wrong documentation suggesting it does?

      Abigail

        From 'man perlop':
        If you want such a pattern to be compiled only once, add a "/o" after the trailing delimiter. This avoids expensive run-time recompilations, and is useful when the value you are interpolating won't change over the life of the script.

        Same thing in camel book (3rd ed.) p.148.