Solved

help with concordance

Posted on 2001-06-13
11
271 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
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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

 
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

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…
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
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…

856 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