Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Regexp::Grammars' <log: ...> directive

by Anonymous Monk
on Jul 14, 2022 at 15:42 UTC ( [id://11145525]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

How does one make use of Regexp::Grammars "<log: ...>" directive? I presumed that the following code should output "via log" to the logfile (STDERR in this case) but it never appears.

#!/usr/bin/env perl use v5.32.01; use Data::Dumper; my $parser = do { use Regexp::Grammars; qr{ <logfile: - > <nocontext:> <Yada> <token: Yada> <log: via log> # <warning: via warning> <error: via error> <fatal: via fatal> yada }ixms; if ('yada' =~ $parser) { warn Data::Dumper->new([\@!,\%/],[qw(*! */)])->Deepcopy(1)->Indent +(1)->Maxdepth(0)->Sortkeys(1)->Dump(),q{ }; } else { say {*STDERR} $_ for @!; # i.e. report all errors };

Replies are listed 'Best First'.
Re: Regexp::Grammars' <log: ...> directive
by haukex (Archbishop) on Jul 16, 2022 at 11:52 UTC

    For me, the log message does show up when I turn on debugging via e.g. <debug: run>. Note you need to remove the <error: > and <fatal: > directives for the match to complete successfully. Also, your code doesn't compile, it's missing a closing } on the do block.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://11145525]
Approved by hippo
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (1)
As of 2024-04-24 15:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found