For your consideration:
package Employee; sub spawn { my $class = shift; my $self = { empid => 200, name => "Joe", pay => 20, @_, }; return bless $self, $class; } sub get_name { my $self = shift; return $self->{name}; } sub set_name { my $self = shift; $self->{name} = shift; } sub get_pay { my $self = shift; return $self->{pay}; } sub set_pay { my $self = shift; $self->{pay} = shift; } package main; $wk1 = Employee->spawn(name=>"Joe", empid=>201, pay=>25); $wk2 = Employee->spawn(name=>"Moe"); $wk3 = Employee->spawn(name=>"Bob", empid=>202); print $wk1->get_name," Earns ",$wk1->get_pay," dollars per hour. His/h +er Emp ID is: ",$wk1->{empid}; print $wk2->get_name," Earns ",$wk2->get_pay," dollars per hour. His/h +er Emp ID is: ",$wk2->{empid}; print $wk3->get_name," Earns ",$wk3->get_pay," dollars per hour. His/h +er Emp ID is: ",$wk3->{empid}; print "Got this far!"; $wk1->set_pay(70); $wk2->set_name("NewMoe"); use Data::Dumper; print Dumper $wk1; print Dumper $wk2; print Dumper $wk3;

In reply to Re: "Can't locate object method" error by Anonymous Monk
in thread "Can't locate object method" error by doctor T

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.