http://www.perlmonks.org?node_id=1231658


in reply to Re: Something eq hashref key
in thread Something eq hashref key

On a side note, it's a pity we can't use exists on hash slices ...

DB<9> exists @h{"a","z"} exists argument is not a HASH or ARRAY element or a subroutine at (eva +l 18)...

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

Replies are listed 'Best First'.
Re^3: Something eq hashref key
by hdb (Monsignor) on Mar 25, 2019 at 14:17 UTC

    In a recent thread it was shown that hash slices are not faster than maps, exists on hash slices is not needed.

    sub slex { my $h = shift; return map { exists $h->{$_} || 0 } @_ } my %h = map { $_ => 1 } 'a'..'t'; my @bool = slex \%h, 'a'..'z'; print "@bool\n";
      You must be joking! (?)

      The benchmark was about non intuitive performance of constant lists.

      Slices are 5 times faster than maps in this example, and the overhead of join is still included

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery FootballPerl is like chess, only without the dice