Solved

help with concordance

Posted on 2001-06-13
11
273 Views
Last Modified: 2010-03-05
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
Comment
Question by:Kitty__Kong
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
11 Comments
 
LVL 8

Accepted Solution

by:
shlomoy earned 100 total points
ID: 6189509
0
 
LVL 8

Expert Comment

by:shlomoy
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

by:Kitty__Kong
ID: 6189637
nothing is getting printed with that code
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 8

Expert Comment

by:shlomoy
ID: 6189741
did you define $filename?
did you define $findme?
0
 
LVL 1

Author Comment

by:Kitty__Kong
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

by:shlomoy
ID: 6191116
and you didn't see anything?!
0
 
LVL 1

Author Comment

by:Kitty__Kong
ID: 6192189
nothing prints
0
 
LVL 8

Expert Comment

by:shlomoy
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

by:maneshr
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.

Experts ===>: please leave your thoughts here. <====

maneshr
(NOT a moderator at EE)
0
 
LVL 1

Author Comment

by:Kitty__Kong
ID: 6972790
well i still havent gotten the answer
0
 
LVL 5

Expert Comment

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

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question