in reply to Search string within an predefined array
But it won't work that way, because if you break out of the loop in the else branch, you're just checking the first item. Maybe just set a variable to a true value in the if branch, and do the print after the loop.
That said, this kind of problem is usually solved with hashes instead:
my @defstream = ("HF","HFB","MB","BF"); my %d; @d{@defstream} = (1) x @defstream: if ($d{$dfs}) { ... } else { ... }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Search string within an predefined array
by ack (Deacon) on Jan 16, 2009 at 16:27 UTC | |
Re^2: Search string within an predefined array
by hbm (Hermit) on Jan 16, 2009 at 17:02 UTC | |
Re^2: Search string within an predefined array
by dilip_val (Acolyte) on Jan 16, 2009 at 17:41 UTC | |
by toolic (Bishop) on Jan 16, 2009 at 18:20 UTC |