title: Perl module that accepts list and creates objects
body: <p>I am working on an college problem ( in Perl ). We are working on creating modules and I need to write a simple module that "has get/set methods for four attributes: lastname, firstname, full_name and a list of children who are also person objects".</p>
  
  <p>I think I have it down but it's the list of children who are also person objects that throws me. I guess the module needs to accept a list and then create a list of objects? Python is my core language so this one is throwing me. The get/set methods are working fine. Any ideas?</p>
  
  <p>My module is here...</p>
  
  <pre><code>#!/usr/bin/perl
  
  package Person;
  
  sub new
  {
      my $class = shift;
      my $self = {
          _firstName =&gt; shift,
          _lastName  =&gt; shift,
      };
      bless $self, $class;
      return $self;
  }
  sub setFirstName {
      my ( $self, $firstName ) = @_;
      $self-&gt;{_firstName} = $firstName if defined($firstName);
      return $self-&gt;{_firstName};
  }
  
  sub getFirstName {
      my( $self ) = @_;
      return $self-&gt;{_firstName};
  }
  
  sub setLastName {
      my ( $self, $lastName ) = @_;
      $self-&gt;{_lastName} = $lastName if defined($lastName);
      return $self-&gt;{_lastName};
  }
  
  sub getLastName {
      my( $self ) = @_;
      return $self-&gt;{_lastName};
  }
  
  sub getFullName {
      my( $self ) = @_;
      return $self-&gt;{_lastName}.",".$self-&gt;{_firstName};
  }
  
  1;
  </code></pre>
  
  <p>My code is here.....</p>
  
  <pre><code>#!/usr/bin/perl
  
  use Person;
  
  $object = new Person("Elvis","Presley");
  # Get first name which is set using constructor.
  $firstName = $object-&gt;getFirstName();
  $lastName = $object-&gt;getLastName();
  $fullname = $object-&gt;getFullName();
  
  print "(Getting) First Name is : $firstName\n";
  print "(Getting) Last Name is: $lastName\n";
  print "(Getting) Full Name is: $fullname\n";
  </code></pre>