Brothers,
I am having trouble with calling new within one package to create an object from a different one. Within the code below the call to new within the s1 subroutine gives me an error:
Bareword "T" not allowed while "strict subs" in use
but I don't see why that is different from the code
10 lines higher up. What am I missing?
use strict;
use warnings;
{
# This works
my $l2 = new T;
my $l1 = new P;
exit 0;
}
{
package P;
sub new
{
my $self = {};
bless $self,shift;
# This call works
my $t1 = new T;
return $self;
}
sub s1
{
# This call complains that
# Bareword "T" not allowed
# while "strict subs" in use
my $t1 = new T;
}
}
sub s2
{
# Even this works
my $t1 = new T;
}
{
package T;
sub new
{ return bless {},shift; }
}
Update:Added s2 subroutine to prove that it is something to do with packages. Also this is on Perl 5.6.1 from ActiveState running on a Windows 2000 box (but I doubt that makes a difference)