in reply to Re: Error in coverage module
in thread Error in coverage module

Hm, thanks, did not know about $foo =~ q/oo/ ... but why would you use q instead of m?


The way forward always starts with a minimal test.

Replies are listed 'Best First'.
Re^3: Error in coverage module
by AnomalousMonk (Archbishop) on Oct 16, 2019 at 00:02 UTC

    In something like
        print 'match' if $file =~ q|/Devel/|;
    I'd be inclined to use  qr|/Devel/| or better yet  qr{ /Devel/ }xms (for various arcane reasons), or m//. But it may sometimes be useful to match directly against a string, either as a literal (but this seems rather quirky to me) or in a variable; as an example of the latter:
        my $string = <$filehandle>;
        ...
        do_something() if $something_else =~ $string;
    (Of course, matching against a string read from an external source may have issues with metacharacter quoting, sanitization, etc.)


    Give a man a fish:  <%-{-{-{-<

      > I'd be inclined to use qr|/Devel/| or m//

      single quotes have no variable interpolation

      DB<47> $s="a" DB<48> p "a" =~ qr($s) 1 DB<49> p "a" =~ '$s' # same as q() DB<50>

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery FootballPerl is like chess, only without the dice