Discussion:
Can't use an undefined value as a HASH reference at
Jerry DuVal
2006-07-21 19:08:55 UTC
Permalink
When trying to use the class below I keep getting this error message. Any
idea's, I have tried everything.



Can't use an undefined value as a HASH reference at
/usr/share/perl5/Pace/Sockets/Client.pm line 37.

ERROR - Aborting abnormally... error code = 2 message = Can't use an
undefined value as a HASH reference at
/usr/share/perl5/Pace/Sockets/Client.pm line 37.



ERROR - Aborting abnormally... error code = 2 message = Can't use an
undefined value as a HASH reference at
/usr/share/perl5/Pace/Sockets/Client.pm line 37.



use strict;

use warnings;

use Pace::Logging::Logger;



package Pace::Sockets::Client;



sub new {

my $class = shift;

my $self = {};

my $logger = Pace::Logging::Logger->new("Sockets::Client");

my $log = $logger->getLog();

my %data = (user=>'sdfgdfg', pass=>'sdfgsdfgsdfg');

$self->{LOGGER} = $log;

$self->{DATA} = \%data;

bless ($self, $class);

return $self;

}



sub sendFile

{

my $self = shift;

my $command = $_[0];

my $fromFile = $_[1];

my $toFile = $_[2];

my $client = $self->{CLIENT};

my %hash = %{$self->{DATA}};

my $hash = %hash;

my $reply = '';

start1();

}



sub start1

{

my $self = shift;

my %hash = %{$self->{DATA}};

my $hash = %hash;

$self->getLogger()->info($hash);

$self->getLogger()->info("Attempting to connection
to socket.");

}



1; # so the require or use succeeds
Mumia W.
2006-07-21 20:30:17 UTC
Permalink
Post by Jerry DuVal
When trying to use the class below I keep getting this error message. Any
idea's, I have tried everything.
Can't use an undefined value as a HASH reference at
/usr/share/perl5/Pace/Sockets/Client.pm line 37.
[...]
sub start1
{
my $self = shift;
my %hash = %{$self->{DATA}};
my $hash = %hash;
[...]
I can't be sure what line is line 37 because your program
formatted "strangely" in my mail-reader, but if {DATA} is not
defined for that hash (self), it'll create the error you got.

Also, what is "my $hash = %hash" intended to do? Print the
contents of $hash, and you'll probably be surprised. Perhaps
you wanted a slash before that %hash to create a reference.
--
To unsubscribe, e-mail: beginners-***@perl.org
For additional commands, e-mail: beginners-***@perl.org
<http://learn.perl.org/> <http://learn.perl.org/first-response>
Loading...