David O'Dell wrote:
> I'm sure there is a way to shorten the way I'm performing this test
> statement.
> In the script below the test statement is looking for two separate
> conditions.
> Is there a way to shorten  it by not having to specify the variable
> twice? Thanks in advance
> 
> #!/usr/local/bin/perl -w
> @LIST = qw(fred joe bob john dude eddie rob);
> foreach $i(@LIST){
>         if ($i =~ "joe" | $i =~ "dude"){          #<--- this is what I
> want to shorten-------->#
>         print "$i\n";}
>         }

        If unique then change to a hash and either uc or lc the keys and now you will 
know quickly:


#!/usr/local/bin/perl -w
my %LIST = qw(fred 1 joe 1 bob 1 john 1 dude 1 eddie 1 rob 1 );
my @Search = qw(joe dude);
foreach my $i ( @Search ) {
  if (defined $LIST{$i} ){          
     print "$i\n";
   }
 }

Wags ;)


**********************************************************
This message contains information that is confidential
and proprietary to FedEx Freight or its affiliates.
It is intended only for the recipient named and for
the express purpose(s) described therein.
Any other use is prohibited.
****************************************************************


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to