Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
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 meditating upon the Monastery: (5)
As of 2015-07-02 04:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (27 votes), past polls