Oh, I forgot to write down the line numbers. Line 21 is
$self->{friends}->{'Juergen'} = "Sonja";
in the "TestObject.pm". So it's the first access to the hash-array. I'm searching the problem since some days. So I would be happy if anyone could explain the problem with the hash.
Thanks in advance Luis
Luis schrieb:
Hi,
I have a problem. The following code results a
"Can't use string ("1") as a HASH ref while "strict refs" in use at TestObject.pm line 21."
Error if I include the "use strict" command. I don't understand why this error occures. Any suggestions??
First the object (TestObject.pm): ################################## package TestObject;
use warnings; use strict; require Exporter; our @ISA = qw(Exporter);
sub new { my ($package, $opt) = @_; my $self = bless { 'opt' => $opt, 'friends' => {}, }, $package; print "Object TestObject created with Options $opt\n"; $self->insertFriends; return $self; }
sub insertFriends {
my $self = @_;
$self->{friends}->{'Juergen'} = "Sonja";
$self->{friends}->{'Andi'} = "Birte";
$self->{friends}->{'Philipp'} = "Susi";
$self->{friends}->{'Markus'} = ""; }
##################################
Now the main-program (TestTestObject.pl): ################################## #!/usr/bin/perl
use strict; use warnings; require TestObject;
my $obj = new TestObject "Blablabla"; ##################################
Thanks Luis
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>