in reply to Searching mixed array?

See also List::MoreUtils::firstidx
use warnings; use strict; use List::MoreUtils qw(firstidx); my @fsg = (1, 2, 4, 5, qw(A B C)); printf "item with index %i in list is B\n", firstidx { $_ eq 'B' } @fs +g; printf "item with index %i in list is 2\n", firstidx { $_ eq 2 } @fsg; __END__ item with index 5 in list is B item with index 1 in list is 2
use strict and warnings

Replies are listed 'Best First'.
Re^2: Searching mixed array?
by edieguez (Initiate) on Apr 27, 2011 at 02:27 UTC
    Thank you very much everyone for your answers. I’ve just begun learning Perl after many years of using compiled languages such as C/C++. Although I seem to have made an elementary mistake in this case, I am very impressed at how quickly one can become productive with Perl. I am using it to do some statistical analysis in support of a few Natural Language Processing algorithms I am developing.
      If you are performing more than very basic statistical analyses, you should take a look at Bundle::Math::Statistics and the modules it contains - it may save you a lot of effort.