Points.

  1. If you have already called local on $/, it is already undefined. So that line is redundant.
  2. You can indeed move the my into the open.
  3. I prefer seeing parentheses there. You don't actually need them, but I write them anyways. Besides which, if you aren't in the habit of writing them, it is too easy for someone copying you to decide they like writing or as || and not know they are losing the error check.
  4. Speaking of the error check, you aren't testing $!.
  5. If you are using a 3 argument open already so your code documents what you are doing, then I like having your error message say whether you are reading, etc.
  6. Your factoring of work bothers me. Opening a file and slurping it in are things you are likely to have to write a lot. Slurping it just to scan the file is less likely. So I would prefer to see a function to slurp in the file and a separate one to scan through the slurped in file. Then call one with input from the other. An advantage to this arrangement is that your global is not in an altered state while scan is being called...

In reply to Re (tilly) 1: Code Review on Several Interesting Points by tilly
in thread Code Review on Several Interesting Points by John M. Dlugosz

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.