Solved

How to count 3 keywords  entered by the user..?

Posted on 2002-04-05
10
199 Views
Last Modified: 2010-03-05
sub txtAnalyze {
     my $self = shift;
     my $text = $self->{TEXT};  ## Text that contains the keywords

my $key1_splited  = $self->{EXTRAKEY};

my @key1_splited;
my $tmp;
my $var = ref($key1_splited);

  my $size = scalar(@{$key1_splited});
  print "THE the type is $var and size is $size <br>";

     
foreach $tmp (@{$key1_splited}){
  print "Tmp splitted keys are: $tmp <br>"; # netscape, java, browser
   }


I need to find the keywords in the text file and display the count.

How can i do that?
0
Comment
Question by:sdesar
  • 7
  • 2
10 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 6922193
foreach $tmp (@{$key1_splited}){
   my $count = () = $text =~ /\b\Q$tmp\E\b/gi;
   print "Tmp splitted keys are: $tmp, count = $count<br>";
}
0
 

Author Comment

by:sdesar
ID: 6923247
Thanks a million for your response.

The count works but doesn't seem like its counting right.
I added your code.  It seems like it finds the word and count but does not count the entire text document...

Here's the output-

Extra keys are: 3   netscape
Extra keys are: 1   sizes
Extra keys are: 2   skipper

The html document that I am working with is -
http://208.56.56.72/blaT/Access1.html
0
 

Author Comment

by:sdesar
ID: 6925764
Awaiting suggestions.. and comments from ozo and other perl gurus ....

Thanks !
0
 

Author Comment

by:sdesar
ID: 6931817
Seems like its only counting the first paragraph..
How can I force it to count these words in the entire document.

Thanks
0
 
LVL 84

Expert Comment

by:ozo
ID: 6932061
How are you reading the entire document?
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

Author Comment

by:sdesar
ID: 6934778
The entire document it read from this ..
my $text = $self->{TEXT};  ## Text that contains the keywords

It dump ascii text - based on this-
 my @text = split /\r?\n/, `lynx -dump -width=4000 $url`;

To view the site visit -
http://208.56.56.72/blaT/frame1.html
the
html page to enter is
http://208.56.56.72/blaT/Access1.html

Let me know if you need more details.


Thanks for all your help.
0
 

Author Comment

by:sdesar
ID: 6938144
Hello Ozo,
I would like to know if you have had some time to review this question.
Thanks!
0
 

Author Comment

by:sdesar
ID: 6943269
Thanks ozo for all your help.
Your suggestion as descript works wonderful.
But the reason it coesn't count some words is because of a word like "hey there mr.,SKIPPER; hello world"

There's a " ,  " Before the word and also " ; " after and as a result the KEYWORD gets ignored from the count.
Any suggestions on how to modify the script so it counts SKIPPER but ignores the comma and semicolon.


Here's the script you suggested-

foreach $tmp (@{$key1_splited}){
 print "Tmp splitted keys are: $tmp <br>"; # netscape, java, browser
  }

Thanks.
0
 

Author Comment

by:sdesar
ID: 6966455
I am deleting this question because ozo helped me with this in another question that i had.

THanks
0
 
LVL 6

Accepted Solution

by:
Mindphaser earned 0 total points
ID: 7047444
Points refunded and moved to PAQ

** Mindphaser - Community Support Moderator **
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

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 …
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
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…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

707 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

15 Experts available now in Live!

Get 1:1 Help Now