Dear Monks,
I am going mad with this so please help. I have two arrays and if an element in 1st array is in 2nd array I want to append "+" to array 3. If it's not I want to append '-' to array 3. It's simple with if and grep but I want to finally start making my code shorter. I tried different varation of;
@x = qw(6); @y = qw(1 2 3 4); foreach $x (@x) { any{$x == $_ } @y ? push(@z, "y") : push(@z, "n"); }
I relize there are probably tons of ways to make it simpler but I can someone tell me what to change in this to make it work? I really want to use the ? : ; scheme properly in such cases so I can use it in the future.
Perl Apprentice
In reply to Failed array attemp by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |