in reply to Most efficient way of search elements in an array
use strict; use warnings; my @results_file = (1,1,1,0,1); for (@results_file) { if (/0/) { print "\n--FAIL--\n"; last; } else { print "\n--PASS--STATUS\n"; print "\n$_\n"; } } __END__ --PASS--STATUS 1 --PASS--STATUS 1 --PASS--STATUS 1 --FAIL--
Update: Or maybe this is the output you were looking for...
use strict; use warnings; my @results_file = (1,1,1,0,1); my $pass = 1; for (@results_file) { if (/0/) { print "\n--FAIL--\n"; $pass = 0; last; } } if ($pass) { print "\n--PASS--STATUS\n"; print "\n@results_file\n"; } __END__ --FAIL--
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Most efficient way of search elements in an array
by sqspat (Acolyte) on Sep 15, 2009 at 15:16 UTC | |
by toolic (Bishop) on Sep 15, 2009 at 15:23 UTC |