Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Re^2: Use hashes instead of grep

by space_monk (Chaplain)
on Nov 15, 2012 at 10:55 UTC ( #1003988=note: print w/replies, xml ) Need Help??

in reply to Re: Use hashes instead of grep
in thread How to grep exact string

Not really. Even if the code uses both arrays then there is nothing preventing building a temporary hash through
my %hash = map { $_ => 1 } @first_list;
..and then discarding the hash after the check for new machines. More likely is that he is only interested in the second list, or just new machines, and they could be in an array just like before.
A Monk aims to give answers to those who have none, and to learn from those who know more.

Replies are listed 'Best First'.
Re^3: Use hashes instead of grep
by ColonelPanic (Friar) on Nov 15, 2012 at 11:15 UTC
    Yes, but this method is not clearly superior if arrays are needed for other purposes. The array comparison is simpler, uses less memory, and will be fast unless both files are huge.

    When's the last time you used duct tape on a duct? --Larry Wall

      Or, as Darth put it:

      The time to build the structure is insignificant compared to the power of the hash!
      The code to implement the hash version isn't significantly more complex - see the version in another nodelet for how it would go.
      A Monk aims to give answers to those who have none, and to learn from those who know more.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1003988]
[erix]: spies should use a type-writer, no power needed, no auditable
[erix]: if all else fails, eat the paper
[erix]: a few years ago there was suddenly the news that the Kremlin was using typewriters again. Heard nothing about it afterward
[erix]: (maybe that means it worked)
[oiskuu]: Yeah, it might work as long as there are no root exploits. ;-)
[Corion]: Also, it's much harder to leak paper sheets than it is to leak documents that are available electronically
[oiskuu]: tye, do you make use of remote logging?

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (7)
As of 2017-06-23 20:22 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (555 votes). Check out past polls.