in reply to Search an array for values sequentially

is not complicated as you think:
#untested
#!perl use strict; use warnings; my @preferred = qw(best good normal bad worst); my @routers = qw (asda adsas asdasds); foreach my $router(@routers){ my $best_of = best_of($router); } sub best_of { my $router = shift; my %available; @available{get_available($router)};# get_available return a list # used as keys of %available ha +sh # for our comfort map { return $_ if exists %avalable{$_} } @preferred; }
There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

Replies are listed 'Best First'.
Re^2: Search an array for values sequentially
by AnomalousMonk (Archbishop) on May 20, 2014 at 12:43 UTC
    my %available;
    @available{get_available($router)};# get_available return a list
    c:\@Work\Perl\monks>perl -wMstrict -MData::Dump -le "my %h; @h{ qw(a b c) }; dd \%h; " Useless use of hash slice in void context at -e line 1. {} c:\@Work\Perl\monks>perl -wMstrict -MData::Dump -le "my %h; @h{ qw(a b c) } = undef; dd \%h; " { a => undef, b => undef, c => undef }