Jigar
Jigar

Reputation: 93

Which is more efficient, Perl pattern matching or grep?

Which is the more efficient pattern matching on Linux systems?

Upvotes: 2

Views: 3408

Answers (2)

nap
nap

Reputation: 1

I found the best way for me.

Before I had an array of thousands elements and grep'ped another list of thousands elements to get additional information from the array.

Now I put one time my array to array of hashes and then each time get data from it very quickly.

Was:

@ua1 = grep /$ip/, @ua;

Now:

$ua1[0] = $adrs{$ip};

Upvotes: 0

Zombo
Zombo

Reputation: 1

Russ Cox of Bell Labs wrote a great article about this in 2007. In it he shows how grep uses
non-deterministic finite automata to improve speed over Perl and others.

perl grep

Regular Expression Matching Can Be Simple And Fast

Upvotes: 12

Related Questions