Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

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 all is quiet...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (8)
As of 2017-02-23 20:14 GMT
Find Nodes?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?

    Results (351 votes). Check out past polls.