Use a HASH instead of an array
[EMAIL PROTECTED] on 27 Jun 2003 14:27 Sent by: [EMAIL PROTECTED] To: [EMAIL PROTECTED] cc: bcc: Subject: [Perl-unix-users] Nesting foreach using multiple arrays Hi, new to the list here; quick question ! How do I nest multiple arrays in one 'foreach' statement ? ex. @animals = ("cat", "dog", "ferret", "mouse" ); @petfood = ("meow mix", "dog chow", "ferret food", "mouse food" ); foreach $object (@animals) { print "animal = $object and food = @petfood"; } The results I am lookg for are animal = cat and food = meow mix animal = dog and food = dog chow animal = ferret and food = ferret food animal = mouse and food = mouse food Thanks alot for you help Is there a better way of doing this also ? **DAN** *************************************************************************** This message originated from the Internet. Its originator may, or may not be who they claim to be, and the information contained herein may, or may not be accurate. *************************************************************************** (See attached file: C.htm) _____________________________________________________ This transmission has been issued by a member of the HSBC Group "HSBC" for the information of the addressee only and should not be reproduced and / or distributed to any other person. Each page attached hereto must be read in conjunction with any disclaimer which forms part of it. Unless otherwise stated, this transmission is neither an offer nor the solicitation of an offer to sell or purchase any investment. Its contents are based on information obtained from sources believed to be reliable but HSBC makes no representation and accepts no responsibility or liability as to its completeness or accuracy.
Hi, new to the list here; quick question !
How do I nest multiple arrays in one 'foreach' statement ?
ex.
@animals = ("cat",
"dog",
"ferret",
"mouse"
);
@petfood = ("meow mix",
"dog chow",
"ferret food",
"mouse food"
);
foreach $object (@animals) {
print "animal = $object and food = @petfood";
}
The results I am lookg for are
animal = cat and food = meow mix
animal = dog and food = dog chow
animal = ferret and food = ferret food
animal = mouse and food = mouse food
Thanks alot for you help
Is there a better way of doing this also ?
**DAN**
***************************************************************************
This message originated from the Internet. Its originator
may, or may not be who they claim to be, and the information
contained herein may, or may not be accurate.
***************************************************************************