Pathologically Eclectic Rubbish Lister | |
PerlMonks |
(Ovid - quick fix to your new constructor) Re(2): perl ooby Ovid (Cardinal) |
on Jan 15, 2001 at 23:48 UTC ( [id://52030]=note: print w/replies, xml ) | Need Help?? |
OeufMayo: you have the right idea, but you're on the wrong track and are a bit confused about context.
The left side is a scalar, which means the array '@_' is being called in scalar context. As a result, $class will be set to the number of elements in @_. Also, you want curly braces '{}' in the "my $self =" line to create the reference to the anonymous hash. The following should work: Putting the parenthesis around $class in the first line of the sub causes it to be evaluated in list context and grabs the first element of @_. There are still better ways to write that, but I'll leave it at that for now. Hope this helps!
Cheers, Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.
In Section
Seekers of Perl Wisdom
|
|