31.08.2015, 17:25, "yary" :
> Once in a while, our sysadmin tweaks something on an upstream mail server,
> and asks us a few days later if our spam rate has changed. I invariably whip
> up a perl5 one liner like this to get a daily spam count from my "mh" mail
> folder:
>
> scan +spam|perl -na
Not pretty, also you'll have to take care of -a switch,
perl6 -ne 'our %d; %d{ .trim.split(/\s+/)[1] }++; END {say "$_: %d{$_}" for
sort keys %d}'
31.08.2015, 17:25, "yary" :
> Once in a while, our sysadmin tweaks something on an upstream mail server,
> and asks us a few days later if our spa
This is actually bad decision. If I'm concerned with *my* one-liner I'll use
-Mstrict and all would be great.
On the other hand, most of the time one-liners use one or two variables. Now,
how difficult is for human to track these two?
ps. -M-strict (no strict) is not valid command line option, s
Timo tnx for the reply,
as I was looking for something like mojolicious non-blocking server I've taken
a look at https://github.com/tony-o/perl6-http-server-async/ and now I
understand what async being "crashy" means. I guess I'll have to wait until
production version comes out.
regards
14
If you're not married to the "key : value" format, you could use this:
scan +spam | perl6 -ne 'my %d; %d{.words[1]}++; END { .say for sort %d
}'
Here's another variation, but keeping your original format:
scan +spam | perl6 -ne 'my %d; %d{.words[1]}++; END { say "$_.key() :
$_.value()"
Scoping of lexical looks interesting
perl6 -ne 'my %d; %d{ .words[1] }++; END { %d.sort.perl.say }'
as this could not work in perl5
perl -nE 'my $d =1; END { say $d//"default!" }' # gives default
Btw, is there some option like perl -MO=Deparse -e .. in perl6?
01.09.2015, 17:03, "Jonathan S
On Tue, Sep 1, 2015 at 5:41 PM, Matija Papec wrote:
> Scoping of lexical looks interesting
>
> perl6 -ne 'my %d; %d{ .words[1] }++; END { %d.sort.perl.say }'
>
> as this could not work in perl5
>
> perl -nE 'my $d =1; END { say $d//"default!" }' # gives default
>
It's not the scoping. It's sc
01.09.2015, 19:46, "The Sidhekin" :
>> perl6 -ne 'my %d; %d{ .words[1] }++; END { %d.sort.perl.say }'
>>
>> as this could not work in perl5
>>
>> perl -nE 'my $d =1; END { say $d//"default!" }' # gives default
>
> It's not the scoping. It's scoped correctly, it's just that you need to
> gi