Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Help with accepting inputs, wordcount, and print to a file

by polymorpheus (Novice)
on Sep 10, 2012 at 17:21 UTC ( [id://992812]=note: print w/replies, xml ) Need Help??


in reply to Help with accepting inputs, wordcount, and print to a file

Here are some pointers in the right direction with no code ;-)

1) It is good to see you checking the open() call for errors and properly converting said errors to an exception (calling die()).

2) You will want to use a lexical scalar variable for file handles and not bare words like IN.

3) Please use more meaningful variable names ($word -> $file_name) 4) You are going to have to look at each line in turn and use regular expressions to check if the line contains the word you are looking for. For this you need to read the perldoc for "perlre". You need to know if your words can span multipel lines or not, what characters can delimit your words (see the \w \W and \b regexp special characters.).

Hope this helps - this seems like a real beginner question, so you will probably have a lot more questions once you dig in further to these topics. Please read the docs that come with perl (perldoc tool) as there is a wealth of information there.

  • Comment on Re: Help with accepting inputs, wordcount, and print to a file

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://992812]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (7)
As of 2024-04-24 10:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found