in reply to Re: Pugs configuration - file locations
in thread Pugs configuration - file locations

That's it. Setting PERL5LIB got past that problem. Now I get
pugs> my $z= "abc12345we678" "abc12345we678" pugs> $z ~~ ?/\d+/ *** Cannot parse regex: \d+ *** Error: Error: Can't use string ("1") as a subroutine ref while "st +rict refs" in use at D:\pugs\perl5\Pugs-Compiler-Rule\lib/Pugs /Compiler/Regex.pm line 85. Bool::False pugs>
Owell...

—John
in Allen, Texas (Dallas metroplex)

Replies are listed 'Best First'.
Re^3: Pugs configuration - file locations
by moritz (Cardinal) on Feb 27, 2008 at 08:59 UTC
    The question mark shouldn't be there. Just $z ~~ /\d+/.

    If you want to coerce that to boolean context, the question mark has to be in front of the expression:

    my $bool = ? $z ~~ m/\d+/
    (Don't know if ~~ or ? has the higher precedence, so you might need parenthesis. But I don't think so ;)
      Why?

      It seems more reasonable to tell the regex engine it has an easier job, close to where it is invoked rather than converting the result. IAC, both forms are taken by Pugs, and every variation (even with no ? ) give the same error.

        It seems more reasonable to tell the regex engine it has an easier job, close to where it is invoked rather than converting the result.

        Note that a regex match has side effects like setting $0, $1 etc., and the full match object is still available in $/ even if the match is performed in boolean context.

        So the optimatzion had to a lot smarter than just detecting boolean context (which propagates anyway, so it's not a question of the used syntax).