in reply to Re: perl oo
in thread perl oo
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 @_.my $class = @_;
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.sub new { my ( $class ) = @_; my $self = { user => $_[1], session => 4556, }; bless($self, $class); return $self; }
Hope this helps!
Cheers,
Ovid
Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.
|
---|