I am trying to push an element into a nested array, but ONLY if it
doesn't already exist. I thought the best way to do this might be the
code I wrote below but it doesn't work.
@{$names{TEST}} = ('Paul', 'Mike');
print "Arrays is: ";
print @{$names{TEST}};
print "\n";
$another_name = "George";
push @{$names{TEST}}, $another_name unless grep ($another_name,
@{$names{TEST}}); # This is the part not working.
print "Arrays is now: ";
print @{$names{TEST}};
I thought that the $another_name scalar would be pushed once a grep of
the nested array shows that it doesn't already exist. How can I make
this work?
-Paul