Re: Array help needed please

2004-05-26 Thread John W. Krahn
William Kolln wrote:
> 
> This is a previous message from April left unanswered.
> 
> Can Anyone Help...thanks if you can!
> 
> I have an array called group_vals.
> 
> This array can be populated by any combination of values
> e.g.  /sp|lp|ep12|ffp|vid|dvd|bx|bkk|cd|csd/
> 
> I want to be able to say that:
> 
> if the array contains any combination of only the values 'cd' and/or 'csd'
> then do x
> otherwise
> if the array contains any combination of any other value other than but also
> including 'cd' and/or 'csd'
> then do y

if ( @group_vals == grep /^cs?d$/, @group_vals ) {
do { x() };
}
else {
do { y() };
}



John
-- 
use Perl;
program
fulfillment

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




Re: Array help needed please

2004-05-26 Thread Jose Alves de Castro
On Wed, 2004-05-26 at 12:05, William Kolln wrote:
> This is a previous message from April left unanswered.
> 
> 
> Can Anyone Help...thanks if you can!
> 
> 
> 
> I have an array called group_vals.
> 
> This array can be populated by any combination of values
> e.g.  /sp|lp|ep12|ffp|vid|dvd|bx|bkk|cd|csd/
> 
> I want to be able to say that:
> 
> if the array contains any combination of only the values 'cd' and/or 'csd'

unless ( grep { !/^(?:cd|csd)$/ } @array) {

# you get all the elements of @array that are neither 'cd' nor 'csd'; if
the resulting list is empty, you enter this block

> then do x
> otherwise
> if the array contains any combination of any other value other than but also

}
elsif ( grep { /^(?:cd|csd)$/ } @array and grep { !/^(?:cd|csd)$/ }
@array) {

# i.e., if the array contains at least one element being 'cd' or 'csd'
and if it also contains something that is not any of them (not sure if I
understood what you wanted, though)

> including 'cd' and/or 'csd'
> then do y

}

> William L Kolln

HTH,

jac

PS: If it doesn't, let us know :-)

-- 
Josà Alves de Castro <[EMAIL PROTECTED]>
Telbit - Tecnologias de InformaÃÃo


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




Array help needed please

2004-05-26 Thread William Kolln
This is a previous message from April left unanswered.


Can Anyone Help...thanks if you can!



I have an array called group_vals.

This array can be populated by any combination of values
e.g.  /sp|lp|ep12|ffp|vid|dvd|bx|bkk|cd|csd/

I want to be able to say that:

if the array contains any combination of only the values 'cd' and/or 'csd'
then do x
otherwise
if the array contains any combination of any other value other than but also
including 'cd' and/or 'csd'
then do y




William L Kolln




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