in reply to Trying to get fancy...

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.

Replies are listed 'Best First'.
Re: Re: Trying to get fancy...
by seanbo (Chaplain) on Nov 28, 2001 at 23:17 UTC
    < nit > If you run this with warnings, it will complain about:
    @listA[0] = [qw(1 foo bar)]; @listB[0] = [qw(1 bar baz)];

    /methinks you meant:
    $listA[0] = [qw(1 foo bar)]; $listB[0] = [qw(1 bar baz)];

    < /nit > Either way, I guess it runs...

    perl -e 'print reverse qw/o b n a e s/;'