Re: Strict Rakudo version of this Perl5 one-liner

2015-09-03 Thread yary
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

Re: Strict Rakudo version of this Perl5 one-liner

2015-09-03 Thread Matija Papec
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

Re: Strict Rakudo version of this Perl5 one-liner

2015-09-02 Thread The Sidhekin
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

Re: Strict Rakudo version of this Perl5 one-liner

2015-09-02 Thread Matija Papec
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

Re: Strict Rakudo version of this Perl5 one-liner

2015-09-02 Thread yary
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

Re: Strict Rakudo version of this Perl5 one-liner

2015-09-02 Thread yary
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

Re: Strict Rakudo version of this Perl5 one-liner

2015-09-02 Thread Elizabeth Mattijsen
> 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 >>

Re: Strict Rakudo version of this Perl5 one-liner

2015-09-02 Thread Matija Papec
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

Re: Strict Rakudo version of this Perl5 one-liner

2015-09-01 Thread The Sidhekin
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

Re: Strict Rakudo version of this Perl5 one-liner

2015-09-01 Thread Matija Papec
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: > >

Re: Strict Rakudo version of this Perl5 one-liner

2015-09-01 Thread Matija Papec
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

Re: Strict Rakudo version of this Perl5 one-liner

2015-09-01 Thread Matija Papec
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

Re: Strict Rakudo version of this Perl5 one-liner

2015-09-01 Thread Jonathan Scott Duff
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() :

Strict Rakudo version of this Perl5 one-liner

2015-08-31 Thread 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 -naE '$d{$F[1]}++; END{say "$_: $d{$_}" for