On 5/31/07, Jonathan Lang <[EMAIL PROTECTED]> wrote:
snip
Again, you have a signature problem.  'sub new($)' says that 'new'
will take a single scalar as a parameter; as such, @_ will only ever
have one value in it: $usr and $pwd will always be set to null.
snip

Well, there is a prototype problem, but it isn't that $ will force new
to only accept one value, but rather that prototypes and OO Perl don't
mix.  Perl simply ignores prototypes on methods.  Also prototypes are
broken*, don't use them.

#!/usr/bin/perl

use strict;
use warnings;

package foo;

sub new ($) {
       my $class = shift;
       return bless { @_ }, $class;
}

package main;

my $foo = foo->new(this => 1, that => 2);

print "this $foo->{this} and that $foo->{that}\n";

* http://library.n0i.net/programming/perl/articles/fm_prototypes/

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to