Look at the grep command in Perl, you can specify a block of code to be applied to each value in the list, perhaps it will help. However, heed the advice of others if you can. I understand that sometimes youre give garbage to work with and best practices go out the window.
Also note that a foreach loop doesnt have a guaranteed order. -Wayne Simmons -- Software Engineer InterSystems USA, Inc. 303-858-1000 ________________________________________ From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: Monday, October 22, 2007 2:13 PM To: activeperl@listserv.ActiveState.com Subject: Index of element in array? Gurus, I'm unable to find this in the Camel, Panther, or Billygoat books, so I'll ask you... Is there a Perl function that returns the index of a given element in an array? For example: my @list = q( apple banana pear grapefruit); my $look4 = "banana"; my $ndx = somefunc( $look4, @list ); # sets $ndx to 1 $look4 = "monkeywrench"; $ndx = somefunc( $look4, @list); # sets $ndx to -1, or maybe undef? I'm trying to find a more elegant way than running a foreach loop over @list. Thanks! Deane Rothenmaier Programmer/Analyst Walgreens Corp. 847-914-5150 A word to the wise ain't necessary, it's the stupid ones who need the advice. -- Bill Cosby _______________________________________________ ActivePerl mailing list ActivePerl@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs