Purdy has asked for the wisdom of the Perl Monks concerning the following question:
I have two arrays (@listA and @listB) which themselves contain references to arrays as each element. I want to get a list of elements in @listB that aren't in @listA, according to the first element of the 'embedded' array (which is there by reference).
# this isn't really the assignment, but showing an example $listA[0] = ['1','foo','bar']; $listB[0] = ['1','bar','baz']; # these prints fine print 'First record from @listA: ' . (@{$listA[0]})[0] . "\n"; print 'First record from @listB: ' . (@{$listB[0]})[0] . "\n"; # We first want to get a list of records # in B that aren't in A my ( $a, $b ); @listToExpire = grep ( ($b = (@{$_})[0] && grep( ($a = (@{$_})[0] && $b != $a), @listA )), @listB );
When I step through the debugger, $a & $b never get defined. Why?
As always, thanks in advance!
Jason
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Trying to get fancy...
by dragonchild (Archbishop) on Nov 28, 2001 at 20:20 UTC | |
by Purdy (Hermit) on Nov 28, 2001 at 20:36 UTC | |
by AidanLee (Chaplain) on Nov 28, 2001 at 20:45 UTC | |
by Purdy (Hermit) on Nov 28, 2001 at 20:48 UTC | |
by buzzcutbuddha (Chaplain) on Nov 29, 2001 at 18:45 UTC | |
|
Re: Trying to get fancy...
by AidanLee (Chaplain) on Nov 28, 2001 at 20:24 UTC | |
|
Re: Trying to get fancy...
by jlongino (Parson) on Nov 28, 2001 at 22:38 UTC | |
by seanbo (Chaplain) on Nov 28, 2001 at 23:17 UTC |