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 reply to Re: Help with accepting inputs, wordcount, and print to a file by polymorpheus
in thread Help with accepting inputs, wordcount, and print to a file by underoathed

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.