in reply to Error in coverage module

(Might be a runaway multi-line // string starting on line 808)

Yes, reading the error message can be helpful. I cannot duplicate the "runaway" suggestion from the command line, but the problem with

c:\@Work\Perl\monks>perl -wMstrict -le "my $file = '/Devel'; print 'hi' if 'xhix' =~ /hi; print 'ho'; print 'he' if $file =~ q|/Devel|; " Bareword found where operator expected at -e line 1, near "Devel" (Missing operator before Devel?) syntax error at -e line 1, near "Devel" Execution of -e aborted due to compilation errors.
is clearly due to a runaway  // in a previous statement.

BTW: Use of a string with a  =~ binding operator is kosher

c:\@Work\Perl\monks>perl -wMstrict -le "my $file = 'foo/Devel/bar'; print 'match' if $file =~ q|/Devel/|; " match
if the quoted string is properly delimited!


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

Replies are listed 'Best First'.
Re^2: Error in coverage module
by 1nickt (Canon) on Oct 15, 2019 at 22:57 UTC

    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.

      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

Re^2: Error in coverage module
by ovedpo15 (Pilgrim) on Oct 17, 2019 at 09:49 UTC
    So what should I change in the code in order to make it work? Why it happens?

      I'm not familiar with the module in question and I don't have time ATM to look into the matter, but why not look at or near line 808 for a "runaway multi-line // string" problem like the one illustrated here. A lot of errors seem to be associated with line 808.


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