Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: How can one define value to call method "display" at line 45?

by poj (Priest)
on Apr 03, 2013 at 14:56 UTC ( #1026870=note: print w/ replies, xml ) Need Help??


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


Comment on Re: How can one define value to call method "display" at line 45?
Select or Download Code
Re^2: How can one define value to call method "display" at line 45?
by supriyoch_2008 (Scribe) on Apr 08, 2013 at 08:24 UTC

    Hi poj,

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

    Regards,

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1026870]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (7)
As of 2014-09-18 23:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (126 votes), past polls