hello people,

removing shell scripts is a good way to learn raku and compare.
today i want to replace this:

    fix () {
        awk -F, '{print $1"     "$2}' |
        sort -u                   |
        awk -F" " '{
            if   (seen == $1) print "\t"$2;
            else { seen = $1; print $1 }
        }'
    }

and i got this:

    fix () perl6 -e '
        my %section;
        lines.map: {
            my ($s,$ss) = .split(",");
            %section{$s;$ss} = 1;
        }
        %section.keys.map:
            { .say for $_ , |%section{$_}.keys.map: {"\t$_"} }
    '

";" to walk in the hoh is really awesome but i don't know even know
from where i know it and what's the object underneath.
it isn't listed in the list of operators
(https://docs.perl6.org/language/operators).

i would like to know because it would be nice to make this block

        my ($s,$ss) = .split(",");
        %section{$s;$ss} = 1;

a one liner so i'm searching for something like

        %section{ .split(",").walkTheHash } = 1;

any help will be warmly welcome.

regards
marc

Reply via email to