I'll skip over the security issues. Let's look at a few things:
What's your accounting
sub-routine suppose to do? Print the paycheck for the user? You're not passing any data to the subroutine. How does the subroutine know which user's paycheck to print?
Why not do something like this?
accounting($Fname, $Lname);
sub accounting {
my $first_name = shift;
my $last_name = shift;
if (not $first_name or not $last_name) {
die "You need a first name and a last name...)
}
Now, you can loop through your accounting file line by line, looking for lines where the $first_name
and $last_name
match.
while (my $lines = <$fh>){
chomp $lines;
my ( $Lname, $Fname, $ssn, $address,
$city, $state, $zip, $payDatek,
$hours, $rate, $taxes,$deductions, $notes) = split /\|/, $lines;
#Skip over non matching lines
next if $Lname ne $last_name and $Fname ne $first_name;
You've got some bogus errors in your code. A few quick ones I noticed:
push @data2, \@fields;
You're pushing a reference of an array into an array.my ( $Lname, $Fname, ... $notes) = %fields;
Field is an array, not a hash.
I'm surprised your program compiled with these issues.
And, please use spaces in your code. It makes it much easier to read and follow.