Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: How Do I Compare Array A to Array B, removing B elements from A.

by merlyn (Sage)
on Mar 21, 2002 at 21:03 UTC ( [id://153422]=note: print w/replies, xml ) Need Help??


in reply to How Do I Compare Array A to Array B, removing B elements from A.

my @C; OUTER: for ( @A ) { for my $pat ( @B ) { if ( /\Q$pat/i ) { next OUTER; } } push @C, $_; }
  • Comment on Re: How Do I Compare Array A to Array B, removing B elements from A.
  • Download Code

Replies are listed 'Best First'.
Re: Answer: How Do I Compare Array A to Array B, removing B elements from A.
by amitbhosale (Acolyte) on Apr 09, 2008 at 07:39 UTC

    other strategy for above solution is.
    @array_one = qw(one two three four); @array_two = qw(three four five six); %array_one = map {$_, 1} @array_one; @difference = grep {!$array_one {$_}} @array_two; print "@difference\n";

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://153422]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (8)
As of 2024-04-23 12:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found