View the step-by-step solution to:

Write a PERL PROGRAM that reads in, displays, and manipulates an array of employee records. An employee record has the following structure: Employee...


1. Write a PERL PROGRAM that reads in, displays, and manipulates an array of employee records.
An employee record has the following structure:
Employee Record:
Name : NameType
Age : Integer
Hourly Rate : Real
Name Type:
First : String
Middle : String
Last : String

The raw data for the employee record is stored in space delimited format in the file employee.txt:

robert francis dugan 40 10.00
rebecca mae dugan 32 15.00
benjamin robert dugan 0 5.00
cricket dory dugan 22 8.00
micheal gerald dugan 39 18.00
carrie marie dugan 40 12.00
timothy joseph dugan 37 15.00
stacy jane dugan 37 19.00
patricia agnes dugan 65 20.00
anne marie dugan 93 12.00

Your program should do the following:

a) Read in the contents of employee.txt into an appropriate set of data structures. You can only read the content of the employee.txt file ONCE at the beginning of the program.

b) Present the following menu of choices:

Employee Management System
1) List employees, age, and hourly rate
2) Display average age
3) Display average hourly rate
4) Display sum of weekly salaries
5) Quit

You should write subroutines to support each of the options on the user menu. The menu subroutines should process the data structure(s) that contain the employee data. Menu options 1-3 and 5 are self explanatory. Menu option 4 should compute the weekly salary for each employee, then sum up the salaries for a single answer.
Place your solution for 1 in a single file called “hw4.f”. Attach a hard copy of your code and a screen snapshot of the execution results to the homework assignment you hand in class.
________________________________________

Q2. Later versions of perl moved beyond the basic types of scalar, array, and hash and introduced a reference type.
Write a Perl subroutine, referenceTypeExample, to demonstrate your understanding of Perl’s reference type:
Create an integer variable “theInt” which is set to 42.
Create an alias for the theInt
Using the alias, increase the value of the integer variable by one
Print out the value of theInt (it should be 43)
Print out the value of the alias
Print out the value of theInt using the the alias
________________________________________

Q3 Support for a reference type means support for dynamic memory allocation. Write a Perl subroutine, dynamicArrayExample, that:
Creates and destroys an dynamic array of 100000 integers, all initialized to 42 500 times.

C++ used “new” and “delete” to allocate/deallocate dynamic memory. How does Perl deallocate dynamic memory?

It’s one thing to TALK about how Perl handles dynamic memory... it’s another thing entirely to SEE how Perl handles dynamic memory. What happens to the size of your Perl program as you make repeated calls to dynamicArray? To answer this question, you may want to use the Windows XP Task Manager to observe the memory consumed by your perl program.

Recently Asked Questions

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

-

Educational Resources
  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question