my $class = ref( $type ) || $type;
####
package Purified::Confusion;
sub new {
# my $proto = shift(@_);
# my $class = ref($proto) || $proto;
# To restore sanity, replace the line below
# with the above two commented lines.
my $class = shift(@_);
bless [@_], $class;
}
sub get {
my $self = shift(@_);
return @$self if ! @_;
return @{$self}[@_];
}
1;
##
##
#!/usr/bin/perl -w
use strict;
use Purified::Confusion;
my $one= Purified::Confusion->new('a');
print $one->get(), $/;
# A quite common idiom in Perl code
# which produces no errors nor warnings:
my $two= $one->new('b');
# ...but that produces not at all what is desired,
# if the module author heeded the FUD; as we see here:
print $two->get(), $/;
##
##
a
Can't locate object method "get" via package "Purified::Confusion=ARRAY(0x182f0d0)" at confusion.pl line 13.
##
##
my $class = ref( $proto ) || $proto;