|Problems? Is your data what you think it is?|
Re: Some helpby tfrayner (Curate)
|on Nov 04, 2001 at 01:30 UTC||Need Help??|
First off, nice bit of code. I only have a couple of points. I would change the newlines in the mailing block to this:
since the <STDIN> call still has a \n and the blank line that this introduces can cause a problem for email clients. Use chomp if you want to strip that newline for clarity.
Secondly, someone's going to tell you so it might as well be me, use strict and warnings. They're really very good :-)
Update: As usual, when I tried applying my own advice, strict and warnings threw up a bunch of problems. Probably the most insightful thing I can say is that you maybe don't want to name three different variables (@lines, $lines and @line) quite such similar names as it leads to confusion.
Now, use strict requires that you be a bit more precise about the scope of your variables. I think the simplest thing here would be to declare those three variables as global (disclaimer: unfortunately I don't have time to go into passing variables into and out of functions. Hopefully someone else will, because globals aren't much fun in anything larger which you write). With that change, and a quick alteration in the $i variable for clarity (and to get around a warning when invoked with the -w warnings switch), I get this as the first part of your code:
With a few more mys here and there (left as an exercise to the reader :-)), this will work under strict and be a cleaner bit of code.