You're asking to do something that's the very definition of looping without using a loop. What do you actually want?
I also sometimes wonder why we regularly get questions how to do things "without a loop"...  but I think what people are typically looking for is just some kind of syntactic shortcut that avoids having to spell out things the cumbersome way. Like, for example in this case:
my @a = qw(foo bar baz); my @b = (1, 42, 99); # unwanted (considered too clumsy): for my $i (0..$#a) { $h{$a[$i]} = $b[$i]; } # or $h{$a[0]} = 1; $h{$a[1]} = 42; $h{$a[2]} = 99; # or ($h{$a[0]}, $h{$a[1]}, $h{$a[2]}) = (1, 42, 99); # wanted: @h{@a} = @b; @h{@a} = (1, 42, 99);
They don't particularly care about the internal implementation, i.e. that something behind the scenes of course will have to do the looping... At least, that's my guess.
In reply to Re^2: use array for hash-keys without loop
by almut
in thread use array for hash-keys without loop
by piccard
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |