Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re: Comparing 2 arrays but ignoring certain patterns

by Kenosis (Priest)
on Jun 29, 2012 at 03:46 UTC ( #979038=note: print w/replies, xml ) Need Help??

in reply to Comparing 2 arrays but ignoring certain patterns

Omit building the hash and try the following grep that uses smart matching:

@newlist = grep !((split /:/)[0] ~~ @removelist), @testlist;


ctahci ctsata_1:25:seed


NetWallah provided excellent fixes for your code, and it generates your desired output. You may still, however, use the above grep that doesn't use a hash.

Replies are listed 'Best First'.
Re^2: Comparing 2 arrays but ignoring certain patterns
by hongping (Novice) on Jun 29, 2012 at 07:12 UTC
    this is no working. syntax error at "]~"
      The smart match operator ( ~~ ) was introduced in perl-5.10, so you'll need perl newer than 5.10 if you want to try it
        is there any other way to do it?

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (10)
As of 2016-10-25 07:23 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (315 votes). Check out past polls.