CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Regular Expressions: Re: [fashimpaur] matching sentences: Edit Log



NuclearClam
Novice

Aug 7, 2002, 12:47 PM


Views: 19414
Re: [fashimpaur] matching sentences

how would i do this with a file? i'd like to get by without having to put the file into a string. this is the part of my program that counts the words, paragraphs, etc. the stuff i've commented out is what needs fixin :\


Code
 while (<FILE>) { 

while (/(\w['\w-]*)/g)
{ $freq{lc $1}++;
$count[0]++; }

$count[2]++ if (/\n$/);

}

## $count[1] = (<FILE>) =~ s/\w+(?=\.)/$&/gm;
$count[2]++; # algorithm is off by one

i've also tried scalar(), which produces an error later in the program.

but then there's also the chance of a sentence ending with a closing parenthesis, bracket, or quote (for example "Take off one for every 'Zig'.") which \w+(?=\.) would ignore. it also miscounts acronyms.

thanks for giving me an idea though Smile i never think to use substitute, shift, tr, etc. in ways other than what they were designed for Unsure




(This post was edited by NuclearClam on Aug 7, 2002, 1:00 PM)


Edit Log:
Post edited by NuclearClam (Novice) on Aug 7, 2002, 12:49 PM
Post edited by NuclearClam (Novice) on Aug 7, 2002, 1:00 PM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives