in reply to How can one define value to call method "display" at line 45?

The new constructor code needs a class parameter like this
{package Student; sub new { my ($class, $name, $age, $regd_no)=@_; my $objref = { NAME => $name, AGE => $age, REGD_NO => $regd_no }; print"\n class: $class\n"; return bless $objref, $class; } ...
and the text file needs to be opened again to read the file a second time
... my @students; open (DNAFILE, '<', $DNAfilename) or die "Perl says $!"; while (<DNAFILE>) { chomp; push @students, Student->new(split /:/); } ...
poj

Replies are listed 'Best First'.
Re^2: How can one define value to call method "display" at line 45?
by supriyoch_2008 (Monk) on Apr 08, 2013 at 08:24 UTC

    Hi poj,

    Thanks. Your code has helped me a lot to solve the problem.

    Regards,