bt707
asked on
Perl grep from array
I have the following array @fimAttributes but have changed it to have two sections, one for blue and one for yellow in this example.
I was using a grep to preform a function based on if the attribute was in the array, but now that I have changed it to two sections in the array I'm not sure how to do the grep on the section that I want.
From the example below, how do I change the grep to grep the blue or yellow section of the array, something simple I'm sure, just not sure what I need to change the grep line to?
Thanks,
my @fimAttributes=(q{blue}=>[qw{
id
alias
c
cn
department
displayname
facsimiletelephonenumber
givenname
manager
jobtitle
userprincipalname}],
q{yello}=>[qw{
givenname
jobtitle
l
mail
mailalias
mailalternateaddress
mobile
o
ou
userprincipalname}]
);
my (@Attributes)=('cn','mail','manager','securitystatus','alias','itbuilding');
my @Attributes1;
foreach my $i (0..$#Attributes) {
unless (grep( /^$Attributes[$i]$/i, @fimAttributes) ) {
push(@Attributes1,$Attributes[$i]);
}
}
@Attributes=@Attributes1;
foreach my $att (@Attributes) {
print "$att\n";
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks,