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

Re^6: Words in Words

by BrowserUk (Pope)
on Oct 01, 2011 at 00:40 UTC ( #928968=note: print w/replies, xml ) Need Help??


in reply to Re^5: Words in Words
in thread Words in Words

Another tweak should improve performance again:

#! perl -slw use strict; my @words = do{ local @ARGV = 'words.txt'; <> }; chomp @words; my $all = join ' ', @words; my $start = time; for my $i ( @words ) { while( $all =~ m[ ([^ ]*$i[^ ]*) ]g ) { my $j = $1; next if $j eq $i or $j eq "${i}s" or $j eq "${i}'s"; print "$j contains $i"; last; ## Added } } printf STDERR "Took %d seconds for %d words\n", time() - $start, scalar @words;

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://928968]
help
Chatterbox?
[1nickt]: hippo lately I can tell just by the fact that Anonymous posts a reply after some hours that it is more than likely That Monk.
[virtualsue]: weird. my p6 simple web spider fails to extract anchor tags from perlmonks.org
[holli]: Nice. Turns out I don't have to remove Sweet home Alabama from my playlist ;)
[Corion]: virtualsue: We have some links with a newline between <a and the attributes, maybe your extractor fails to handle that?

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (8)
As of 2017-12-13 11:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (360 votes). Check out past polls.

    Notices?