# wages.pl - An example program to ulustrate some of
#            the features of Perl
#   Input:   A file of lines of employee data, where
#            each line has name, age, department
#            code, salary
#   Output:  1.  The names of all employees whose
#                names end with "son"
#            2.  Percentage of employees under 40
#                years old
#            3.  Average salary of employees under
#                40 years old
#            4.  An alphabetical list of employees
#                who are under 40 years old and who
#                have salaries more than $40,000
#>>> Open the data file and display a head for
#    employees whose names end in 'son'
print "content-type:text/html; charset=utf-8\n\n";
print qq(<HTML><BODY> );
open(EMPLOYEES, "~/public_html/csc271/note/scripts/perl/employees.txt") 
               || die "Can't open employees $!";
print "Names that end in 'son'\n\n";

#>>> Loop to read and process the employee data
while (<EMPLOYEES>)  {
  #>>> Increment the number of employees and chop
  #    off the newline
  $total_employees++;
  chomp;


  #>>> Split the input line into its four parts
  ($name, $age, $dept, $salary) = split(/,/);
    print "$name found $1\n";
}
print qq(</BODY></HTML>);
