Solved

help with concordance

Posted on 2001-06-13
270 Views
can someone please give me the source code to the exercise in this tutorial

http://www.cs.unm.edu/~bwylie/perl/split.html#exercise

im stuck
0
Question by:Kitty__Kong

LVL 8

Accepted Solution

shlomoy earned 100 total points
ID: 6189509
0

LVL 8

Expert Comment

ID: 6189533

open(IN,"<\$filename") or die "Can't open \$filename for reading: \$!\n";
my \$text = join '',<IN>;
close(IN) or die "Can't close \$filename after reading: \$!\n";
my @results = (\$text=~m/((?:\S+[ \t]+){1,5}\$findme[ \t]+(?:\S+[ \t]+){1,5})/gs);
map {print "===>\$_\n";} @results;

0

LVL 1

Author Comment

ID: 6189637
nothing is getting printed with that code
0

LVL 8

Expert Comment

ID: 6189741
did you define \$filename?
did you define \$findme?
0

LVL 1

Author Comment

ID: 6189821
yes this is what i used

\$filename = "electricity.txt";
\$findme = "the";
open(IN,"<\$filename") or die "Can't open \$filename for reading: \$!\n";
my \$text = join '',<IN>;
close(IN) or die "Can't close \$filename after reading: \$!\n";
my @results = (\$text=~m/((?:\S+[ \t]+){1,5}\$findme[ \t]+(?:\S+[ \t]+){1,5})/gs);
map {print "===>\$_\n";} @results;
0

LVL 8

Expert Comment

ID: 6191116
and you didn't see anything?!
0

LVL 1

Author Comment

ID: 6192189
nothing prints
0

LVL 8

Expert Comment

ID: 6192225
then I guess there's nothing with "the".
Perhaps there is "THE" or "The"... but not "the".

If you want case insensitivity add 'i' to the m//;

this way:
m/((?:\S+[ \t]+){1,5}\$findme[ \t]+(?:\S+[ \t]+){1,5})/gsi
0

LVL 16

Expert Comment

ID: 6967713
All,

This question seems to be abandoned. As part of the ongoing cleanup effort, I will leave a note in
the Community Support topic area which will recommend to the Moderators that they close this question.

My recommendation will be to award the points to shlomoy

PLEASE DO NOT AWARD THE POINTS TO ME.

maneshr
(NOT a moderator at EE)
0

LVL 1

Author Comment

ID: 6972790
well i still havent gotten the answer
0

LVL 5

Expert Comment

ID: 6984655
Per recommendation, force-accepted by Netminder, CS Moderator
0

Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question