Just another Perl shrine | |
PerlMonks |
Re: Help with accepting inputs, wordcount, and print to a fileby polymorpheus (Novice) |
on Sep 10, 2012 at 17:21 UTC ( [id://992812]=note: print w/replies, xml ) | Need Help?? |
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.
In Section
Seekers of Perl Wisdom
|
|