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

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:  <%-{-{-{-<

Replies are listed 'Best First'.
Re^4: Error in coverage module
by LanX (Saint) on Oct 16, 2019 at 12:40 UTC
    > 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