Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Concordance Generator - TMTOWTDI

by John M. Dlugosz (Monsignor)
on Aug 14, 2001 at 11:18 UTC ( [id://104687]=note: print w/replies, xml ) Need Help??


in reply to Concordance Generator

These simple, common problems are good learning experiences.

Here's mine, from a discussion on OO in January 1996.

Notice that I used a totally different mechanism to prevent duplicate entries for one line.

sub input { while (<>) { # parse the line into words my %temp; while (/\b\w+\b/g) { ++$temp{$&}; } # add the found words to my global results list my $key; while (($key)=each(%temp)) { push (@{$concord{$key}}, $.); } } } sub output { my @words= sort keys %concord; my $key; foreach $key (@words) { # print "$key @{$concord{$key}}\n" print ("$key ", join (', ', @{$concord{$key}}), "\n"); } } input; output;

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (2)
As of 2024-04-25 20:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found