in reply to More elegant way of doing "ordered hash"?
G'day PopeFelix,
for my $index (0..$#params) { next if $index % 2 == 0; my $parameter = $params[$index]; my $spec = $params[$index + 1]; # do something from here... }Is there a more elegant way of doing that?
How about:
for (grep { not $_ % 2 } 0 .. $#params) { my ($parameter, $spec) = @params[$_, $_+1]; ... }
[ You've got a couple of typos: the 1st $spec becomes $thing; you assign an arrayref to @params ]
-- Ken
|
|---|