My final answer for spam-folder-counting, p5 vs p6:
scan +spam|perl -naE '$d{$F[1]}++; END{say "$_: $d{$_}" for sort keys %d}'
scan +spam|perl6 -e "for lines.map({.words(2)[1]}).Bag.sort {.fmt('%s:%d').say}"
On the surface, very different ways of going about it. Under the hood,
p6's Bag
02.09.2015, 14:49, "Elizabeth Mattijsen" :
>> I think this is covered somewhere in RFC; perl6 repeatedly overwrites
>> END{} block where last one references last %d definition (say %d.WHICH).
>> perl5 on the other hand stays with first END{} block (say \%d).
>
> A much
On Wed, Sep 2, 2015 at 7:49 AM, Matija Papec wrote:
>
> I've picked a wrong example,
>
> seq 3 | perl -nE 'my %d; $d{$_}++; END { say keys %d }'
>
> vs
>
> seq 3 | perl6 -ne 'my %d; %d{$_}++; END { say keys %d }'
>
> So it seems that perl6 handles lexicals inside while
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
On Tue, Sep 1, 2015 at 3:10 AM, Matija Papec wrote:
> Not pretty, also you'll have to take care of -a switch,
S19 calls for -a and -F, surprised Rakudo doesn't have'em! Though from
later examples, the ".words" method is a fine substitute.
On Tue, Sep 1, 2015 at 11:03
On Wed, Sep 2, 2015 at 12:27 PM, yary wrote:
> Do perl6's Bag type and feed operators, or other features, open up a cleaner
> way?
scan +spam|perl6 -e ".say for lines.map({.words(2)[1]}).Bag.sort"
-y
> On 02 Sep 2015, at 14:02, Matija Papec wrote:
> 02.09.2015, 10:46, "The Sidhekin" :
>>> So it seems that perl6 handles lexicals inside while (<>){} one-liners
>>> differently.
>>
>>Ah, yes. Interesting. Run-time effect of C not happening
>>
02.09.2015, 10:46, "The Sidhekin" :
>> So it seems that perl6 handles lexicals inside while (<>){} one-liners
>> differently.
>
> Ah, yes. Interesting. Run-time effect of C not happening repeatedly.
> How would that deparse?
Good question, I wouldn't be surprised
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
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:
>
>
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
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
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() :
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 -naE '$d{$F[1]}++; END{say "$_: $d{$_}" for
14 matches
Mail list logo