Hello Monks, This is a very simple problem but is proving much more difficult than I thought it would and I am on a deadline (and brand new to Perl).
It's a bit of a read but I'll even give you 20$ for your help if you ask for it and solve it before 4 AM tomorrow.
I just have to construct 2 simple classes called Employee and EmployeeList that work kind of like a database for employee information, with a few other functions.
Employee simply needs data members for (name, hours, hourlywage) and a method that calculates the weekly pay and returns it (just hours * hourly wage).

EmployeeList must have a hash as a data member which stores Employee objects. This hash will be initialized in a loop in the calling program. EmployeeList also needs methods to calculate averages of hours, hourlywage across all employees. It then needs a method to respond to a query in the main script and return the employees name, hours, hourlywage. It also needs a method to change the hours or hourlywage.

The EmployeeList class is giving me the most problems. Here's current code for it but it is not remotely working, the main program isn't even functional yet, I wouldn't even mind if you ditched the code that is how lost I am frankly:
package EmployeeList; use diagnostics; use strict; use warnings; sub new{ my ($class) = @_; my $self = bless { EmployeeList => [] }, $class; return $self; } sub get_EmployeeList{ my $self = shift; return $self->{EmployeeList};#does not seem to work at all, no ide +a why } sub set_EmployeeList { my ($self, $new_EmployeeList ) = @_; $self->{EmployeeList } = $new_EmployeeList;#also does not work at +all } sub print_EmployeeList{ my $self = shift; return "Employee info: $self->{EmployeeList}" #Does not even co +me close to working } sub average_hourly_wage{#not even sure where to begin, don't know how +to initialize or access the hash at this point } sub respond_to_query{#again no idea, any help would be great, 20$ or m +ore if you really need it } 1;
Main program:
#!/usr/bin/perl use strict; use warnings; use Employee; use EmployeeList; print "Enter the name of the file to open: "; my $input_file = <STDIN>; chomp $input_file; open(my $file_handle, "<", $input_file) or die "failed to open < input +_file: $!\n"; my @obj_array = (); while (my $row = <$file_handle>){ my @splitrow = split ' ', $row; my $Employee1 = Employee->new({ name =>$splitrow[0], hourlywage =>$splitrow[1], hours =>$splitrow[2] }); print $Employee1->print_Employee(); push @obj_array, $Employee1; }
Employee class (working as far as I can tell):
package Employee; use strict; use warnings; sub new{ my ($class, $args) = @_; my $self = bless { name=> $args->{name}, hourlywage => $args->{hourlywage}, hours => $args->{hours} }, $class; } sub print_student{ my $self = shift; return "Employee info: name: $self->{name} hours: $self->{hours} w +age: $self->{hourlywage}\n" } 1;

In reply to Newbie question under time constraint by crazedrat

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.