develooper Front page | perl.perl6.users | Postings from May 2020

Raku -npe command line usage

Thread Next
From:
WFB
Date:
May 8, 2020 12:16
Subject:
Raku -npe command line usage
Message ID:
CAGXvwmesnQwCBe0c+Hx=V_Eiiw81O4pfDFdWGAo+--Mz9VPgXQ@mail.gmail.com
Hi,

I am trying to write an one-liner to go through all lines in a logfile and
look for an certain key word, store the line and sort them before printing
them out.

My approach was:
raku -ne "BEGIN {my @i }; @i.push($_); if $_ ~~ /^WARN/; END { @i.sort.say
}"
That does not work because @i does not exist in the if clause. I tried our
@i as well with no luck.

How can I store data that can be accessed in the END phaser? Or is there
another way to archive it? TIMTOWTDI^^

One hint I found was the variable $ and @ respectively. But those variables
are created for each line new...


I did not found a help or examples for -npe except raku -h. Is there more
helpful stuff somewhere in doc.raku.org? If so I could'nt find it.

Thanks,
Wolfgang

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About