in reply to Help with strict
You can use a list to store names and still making it efficient for searching elements in the list, without using a hash table -my @masters = qw/ John Paul George Ringo /;
And the output is -use strict; my @masters = qw/ John Paul George Ringo /; sub is_master { my $who = shift; return scalar grep /^$who$/, @masters; } for (qw/ John George James /) { if (is_master($_)) { print "$_ is master\n" } else { print "$_ is not master\n" } }
John is master George is master James is not master
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Help with strict
by sauoq (Abbot) on Oct 29, 2003 at 01:51 UTC |