Hi,
I have the following array.
@a=( ["1","2"],["3","4"]);
and want to
push @a,(["5","6"])
if the 6 is not in the $a[0 .. $#a][1].
This is simplified out of a longer script but im trying for days now and get sick of it.
Can any of you help me on this.
Cheers
Markus
There might be better ways - this is the first that came to mind.
map { grep(/6/, @$_) and $got=1 } @a;
push @a, (["6","6"]) unless $got;
Using a loop rather than map would allow you to break out of the loop as soon
as you see a 6, which might be more efficienti for a big array or a compilcated regexp.
foreach (@a){
grep(/6/, @$_) and $got = 1 and last;
}