Solved

help with concordance

Posted on 2001-06-13
11
267 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
 
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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
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…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

759 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now