G'day jmckinzie,
Welcome to the Monastery.
"Need script help"
Yes, indeed! :-)
While I'm just guessing here,
it looks like you've started with a Bourne-like shell script and attempted to convert it to Perl.
Whether or not that's true,
what you've posted is littered with problems.
I suggest you start by reading
"perlintro -- Perl introduction for beginners".
Then implement what you've learned.
The "Safety net" will highlight many issues and in most cases will tell you where they are and how to fix them.
I expect the most common to be messages like:
Global symbol "$x" requires explicit package name (did you forget to d
+eclare "my $x"?) at <location>
Then, you'll probably get almost as many:
Bareword "xxx" not allowed while "strict subs" in use at <location>
These probably just require quoting (see "perlop: Quote and Quote-like Operators").
When you get to the "Files and I/O" section,
see how the example code differs from yours and follow the links therein for further discussion.
Your posted line
open(DATA, "<$tmpfile") or die "Can't open data";
has additional problems.
DATA (beyond having global scope and all the problems associated with global variables) is actually special to Perl. It doesn't exist by default:
$ perl -E 'say for <DATA>'
Name "main::DATA" used only once: possible typo at -e line 1.
readline() on unopened filehandle DATA at -e line 1.
$
But it will come into existence in circumstances that aren't immediately obvious
(especially for those new to the language).
$ perl -E 'say for <DATA>; __END__'
$
It's good that you've attempted to check I/O problems with "... or die "...";";
however, the message that will be output identifies neither the file nor the problem.
Hand-crafting such checks is tedious and error-prone.
Let Perl do this work for you with the autodie pragma.
Having addressed all of these basic problems,
you can now start looking at issues related to logic, control flow, and so on.
The main one that leaps out me is the two assignments to @eplist without any intervening use of that variable.
Throughout my response, I've used examples like:
perl -E '...'
You should note that I have the environment variable, $PERL5OPT, set to
"-Mstrict -Mwarnings -Mautodie"
(see "perlrun: ENVIRONMENT").
To get the same output as me, either set this variable in your environment, or write the examples like:
perl -Mstrict -Mwarnings -Mautodie -E '...'
|