Ever since I learned you can put an EXPR as the first arg in grep, I've been going grep-crazy. I think I've hit a wall, though, in my ability and could use some guidance/help.

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


In reply to Trying to get fancy... by Purdy

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.