...
| Code Block | ||||
|---|---|---|---|---|
| ||||
{
package Class;
sub new {
my $class = shift;
my $arg = shift;
my $self = bless( {Arg=>$arg}, $class);
print "Class::new called with $arg\n";
return $self;
}
}
sub new {
my $arg = shift;
print "::new called with $arg\n";
}
my $class_to_use = Class;
my $b1 = new Something; # Invokes global new
my $b2 = new Class Something; # Invokes Class::new
my $b3 = new $class_to_use; # Surprise! invokes global new!
|
...
OOP32EXP06-PL. Do not use the two-argument form of open()Prohibit indirect object call syntax
OOP32-PL. Prohibit indirect object call syntax