sqspat has asked for the wisdom of the Perl Monks concerning the following question:
Hello All,
I am trying to find the most efficient way of searching through an array for the value 0 and if it finds a zero it should break out of the search and print a Fail to the test I am running.
I found out the hard way that it is not possible to do a pattern match with an array as below because it does not iterate through the elements; ... doooh !!!
any suggestions?
my @results_file=(1,1,1,0,1); if (@results_file =~ m/0/) { print"\n--FAIL--"; } else { print "\n--PASS--STATUS\n"; print "\n@results_file\n"; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Most efficient way of search elements in an array
by Corion (Patriarch) on Sep 15, 2009 at 14:06 UTC | |
by AnomalousMonk (Archbishop) on Sep 15, 2009 at 15:06 UTC | |
Re: Most efficient way of search elements in an array
by toolic (Bishop) on Sep 15, 2009 at 14:18 UTC | |
by sqspat (Acolyte) on Sep 15, 2009 at 15:16 UTC | |
by toolic (Bishop) on Sep 15, 2009 at 15:23 UTC | |
Re: Most efficient way of search elements in an array
by Fletch (Bishop) on Sep 15, 2009 at 14:10 UTC | |
Re: Most efficient way of search elements in an array
by whakka (Hermit) on Sep 15, 2009 at 14:58 UTC | |
Re: Most efficient way of search elements in an array
by Marshall (Canon) on Sep 15, 2009 at 19:49 UTC | |
Re: Most efficient way of search elements in an array
by ccn (Vicar) on Sep 15, 2009 at 20:04 UTC |
Back to
Seekers of Perl Wisdom