Good and interesting post
Purdy! I've been playing with
the code and following the evolution of the replies. I've
not used LOLs before and found the array syntax(es) not
very intuitive. I borrowed
DragonChilds array
initialization technique and used a map/grep strategy
similar to
AidanLees. For some reason it is easier for me
to grasp
@{$listA[0]} representation than to
break it down further to
$_->[0] constructs.
Maybe more practice (and learning some OOP) on my part will
help.
use strict;
my (@listA, @listB);
$listA[0] = [qw(1 foo bar)];
$listB[0] = [qw(1 bar baz)];
my %hash = map { $_ => 1 } @{$listA[0]};
my @c = grep {! exists $hash{$_}} @{$listB[0]};
print "$_\n" foreach (@c);
--Jim
Update: changed @listX[0] as per
seanbos reply. Thanks seanbo, I originally had it right
but forgot to change it back after an unfruitful experiment.
Should've used -w.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.