in reply to Re: Re: Walks like a regex, quacks like a regex...
in thread Walks like a regex, quacks like a regex...

Well that was (is) my confusion at his mentioning the phrase "a real quoted regex".   _If_ he means a compiled qr() regex then while he's still throwing the result reference value around the ref() is the right way to check.

But once he forces the qr() reference value to be stringified, it'll end up in the "(?-xism:^[Zz]owie!?$)" form and he'll have to recognize that 'unique' format.

And then his checking will fail because the leading part shows which options are and are not in effect.   Using qr{^Zzowie!?$}sm will, when stringified, result in "(?ms-xi:^[Zz]owie!?$)".   Zowie!

  • Comment on Re: Re: Re: Walks like a regex, quacks like a regex...

Replies are listed 'Best First'.
Son of the Bride of Walks like a regex, quacks like a regex...
by legLess (Hermit) on Sep 24, 2003 at 03:45 UTC
    Sweet -- this is exactly the discussion I wanted to see, and a nice answer. I thought of 'ref' earlier, but my perldoc tells me:
    Builtin types include:
    
      SCALAR
      ARRAY
      HASH
      CODE
      REF
      GLOB
      LVALUE
    
    ...so I didn't think it was possible. Thank you.
    --
    man with no legs, inc.

      In the years since I've written this node, UNIVERSAL::isa has been published. Use that instead.


      In that case you should use isa() and test for 'Regex'. You'll allow for blessed regexen this way. Simple ref() tests don't account for that.

      *isa = \&UNIVERSAL::isa; sub regex_tester { my $thingie = shift; return isa( $thingie, 'Regex' ); }