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

Re: Search Algorithm

by t0mas (Priest)
on Aug 10, 2000 at 17:42 UTC ( #27285=note: print w/ replies, xml ) Need Help??

in reply to Search Algorithm

From perldoc -f study:

The following scans a list of files (@files) for a list of words (@words), and prints out the names of those files that contain a match: $search = 'while (<>) { study;'; foreach $word (@words) { $search .= "++\$seen{\$ARGV} if /\\b$word\\b/;\n"; } $search .= "}"; @ARGV = @files; undef $/; eval $search; # this screams $/ = "\n"; # put back to normal input delimiter foreach $file (sort keys(%seen)) { print $file, "\n"; }
Is this what you want?
Anyway, undef $/ will be faster than line by line.

/brother t0mas

Comment on Re: Search Algorithm
Download Code

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (2)
As of 2015-11-28 12:04 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (741 votes), past polls