RE: [Perl-unix-users] Index of array element

2003-12-03 Thread Wagner, David --- Senior Programmer Analyst --- WGO
Title: RE: [Perl-unix-users] Index of array element     You have it as an array, but if unique, then why not setup as hash and you would not have to do any searching, but would know right a way with just a simple test vs searching the whole array each time.   Wags ;) -Original Message-

RE: [Perl-unix-users] Index of array element

2003-12-03 Thread Thomas, Mark - BLS CTR
> I have an array of names. I need to find the corresponding > index for a particular name. How can I do this? If you need to do this often, or for a potentially large amount of names, you may be better off starting with a hash of names instead. -- Mark Thomas[EMAIL PROTEC

RE: [Perl-unix-users] Index of array element

2003-12-03 Thread Peter Eisengrein
Title: RE: [Perl-unix-users] Index of array element are the names unique? If so, a hash would be faster. Nevertheless, I'd do something like my $index; my @names = qw(Bob Mary Fred Julio); my $matchthis = "Fred"; for (my $i = 0; $i < scalar(@names); $i++) {     if ($names[$i] eq $mat

RE: [Perl-unix-users] Index of array element

2003-12-03 Thread Jason Vincent
Title: RE: [Perl-unix-users] Index of array element @array = ('a','b','c'); for($i=0;$i<=$#array;$i++){     print "index is $i\n" if $array[$i] eq 'b'; } J -Original Message- From: Craig Sharp [mailto:[EMAIL PROTECTED]] Sent: Wednesday, December 03, 2003 10:00 AM To: [EMAIL

[Perl-unix-users] Index of array element

2003-12-03 Thread Craig Sharp
I have an array of names. I need to find the corresponding index for a particular name. How can I do this? Thanks, Craig ___ Perl-Unix-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs