in reply to hash and array

it would have been funky to be able to say ++(@hash{@array});
closest to that, $_++ for @hash{@array}; works

Replies are listed 'Best First'.
Re^2: hash and array
by japhy (Canon) on May 22, 2005 at 17:18 UTC
    (Update: Verified.) The Perl 6 code for that be %hash{@array} >>++; which I think is just freaking awesome.

    Jeff japhy Pinyan, P.L., P.M., P.O.D, X.S.: Perl, regex, and perl hacker
    How can we ever be the sold short or the cheated, we who for every service have long ago been overpaid? ~~ Meister Eckhart

      What does the expression %hash{@array} >>++ evaluate to in list context? With sigils just part of the name, I don't have any feel for this yet. But I suppose the evaluation is a property of the >>++ op.

      After Compline,
      Zaxo

        %hash{@array} >>++
        would be pretty much the same as
        %hash{$_}++ for @array
        if I understand correctly. Is that what you are asking? I think >> applies the operation to all of the elements of the array to the left of the >>. The best example of the >> and << things (I don't know what they are called... maybe not operators), would be
        @added = @array1 >>+<< @array2;
        which is like
        ## p5 code, I'm not completely fluent in p6 yet... for ( my $i = 0; i < $#array1; i++ ) { $added[ $i ] = $array1[ $i ] + $array2[ $i ] }

        -Bryan

      just freaking awesome
      beep poop poop beep poop poop beeeep. The results are in, it is freaking awsome :)