in reply to Perl objects

don;t know how to implement it. Note

Then how did you manage to create a class? Show us what you got.

Alternatively, use Moose and read the Modern Perl Released as Free ePub

Replies are listed 'Best First'.
Re^2: Perl objects
by pr09 (Novice) on Jun 14, 2011 at 06:24 UTC
    The project i should have an employee class. The attributes of these class are name,dob etc.. Four methods are to be used like display,update,get and set. The main method should ask the number of employees. Next the user has to enter all the attributes and all this will be saved in a file. Now a method say display method has to called alongwith the argument which you want to retrive,say name. i created a class as shown below: package Employee; sub new { my $self = { _Name => undef; _DOB => undef; }; bless $self,'Employee'; return $self; } sub DisplayDetails { } package main; print "Enter the number of Employees"; $employee_count=<STDIN>; My doubt it how to access this display method using the object.

      My doubt it how to access this display method using the object.

      First you create an object calling class method new

      my $foo = Employee->new;
      Then you call the object method display, on the object $foo
      $foo->display;

      I suggest you review carefully the book/tutorial which taught you about package ... because calling methods is basic syntax.

      Its covered in various places, including the free book Modern Perl a description of how experienced and effective Perl 5 programmers work....You can learn this too.

      Also, FYI, you have a question, not a doubt, see "Question" vs "Doubt"

      The other Anonymous monk
        Thanks for the help. Will read the book.