May 26, 2010, 6:13 AM
Post #4 of 6
Please use the code tags whenever you post code.
Start by adding these 2 lines, which should be in every Perl script you write.
Those pragmas will point out lots of coding errors that can be difficult to track down.
The strict pragma forces you to declare your vars, which is done with the 'my' keyword.
You should always check the return code of an open call to make sure it was successful and take action if it wasn't.
It's best to use the 3 arg form of open and a lexical var for the filehandle instead of the bareword.
open my $file1, '<', $ARGV or die "failed to open '$ARGV $!";
open my $file2, '<', $ARGV or die "failed to open '$ARGV $!";
That is normally written as:
Since the print function is a list operator, your attempt to read in the employee number from file to in the print statement will slurp and print the entire file. Instead, you should assign the employee number to a scalr var and use that var in the print statement.