Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: terrible code about array matching...

by jlongino (Parson)
on Nov 06, 2002 at 15:38 UTC ( #210763=note: print w/replies, xml ) Need Help??


in reply to terrible code about array matching...

I'm not exactly sure what you're trying to do but if you're only trying to validate parameters, something like the following would work:
use strict; use warnings; my %valid = ( peace => 0, child => 1, free => 2, love => 3, enjoy => 4 ); my @test = qw(freely enjoy love); my @parms; for my $test (@test) { if (exists $valid{$test}) { push (@parms, $test); } else { print "\n\nSkipping bad argument '$test'!!!\n\n"; } } print "\n\nValid parms:\n"; print " ", pack('A8',$_), ": position: $valid{$_}\n" for @parms;
Update: After rereading a few times, I realize that the poster needs what chromatic suggested. /me finishes coffee before responding to anymore posts.

--Jim

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://210763]
help
Chatterbox?
[moritz]: good morning
[moritz]: perl -MNetAddr::IP -wE 'say NetAddr::IP->new( "2001:780:233::/ 64")->hostenum' dies with netmask error: overrange or spurious bits at -e line 1.
[moritz]: any idea what's wrong?

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (8)
As of 2017-04-25 07:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (449 votes). Check out past polls.