#!/usr/bin/perl -w
use strict;
my @list = qw(fred joe bob john dude eddie rob dudette joeshmoe);
foreach (@list) {
print "$_\n" if (/joe|dude/);
}
Note that you'll match on dudette and joeshmoe ... if you want an exact
match, you could do:
print "$_\n" if (/^joe|dude$/);
On Thu, 2003-02-27 at 14:26, 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";}
> }
>
>
>
>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]