Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

help with concordance

Posted on 2001-06-13
11
Medium Priority
?
276 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 400 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
Technology Partners: 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

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…
Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
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…
Six Sigma Control Plans

715 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