In your method setA change
$self-> = %{(shift)};
to
$self-> = { _};
hope this helps.
----- Original Message -----
From: sumit_bhattacharjee_2004
To: perl-beginner@yahoogroups.com
Sent: Monday, February 19, 2007 9:47 PM
Subject: [PBML] Passing hash arguments
Hi,
Can anyone help me with this? I just cant figure out what
I am
doing wrong here.keep getting the error "Can't use an
undefined
value as a HASH reference.".
************************************************************
*********
**********************************
==============
Main.pl
==============
#! usr/bin/perl -w
use strict;
use A;
use C;
my $a = new A;
my %has = $a->get;
my $c = new C;
$c->setA(%has);
print $c->getA;
1;
===============
a.pm
===============
#! usr/bin/perl -w
package A;
sub new {
my $self = {};
return bless $self;
}
sub get {
my $self = shift;
my %h =
("1"=>"one","2"=>"t
wo","3"=>"three");
return %h;
}
1;
===============
c.pm
===============
#! usr/bin/perl -w
package C;
sub new {
my $self = {};
$self-> = {};
return bless $self;
}
sub setA {
my $self = shift;
$self-> = %{(shift)};
}
sub getA {
my $self = shift;
return $self->->;
}
1;
************************************************************
*********
***************************************
Thanks in advance for any help!
Sumit
"Legal Disclaimer: This electronic message and all
contents contain information from Cybage Software Private
Limited which may be privileged, confidential, or otherwise
protected from disclosure. The information is intended to be
for the addressee(s) only. If you are not an addressee, any
disclosure, copy, distribution, or use of the contents of
this message is strictly prohibited. If you have received
this electronic message in error please notify the sender by
reply e-mail to and destroy the original message and all
copies. Cybage has taken every reasonable precaution to
minimize the risk of malicious content in the mail, but is
not liable for any damage you may sustain as a result of any
malicious content in this e-mail. You should carry out your
own malicious content checks before opening the e-mail or
attachment."
www.cybage.com
[Non-text portions of this message have been removed]
Unsubscribing info is here: h
ttp://help.yahoo.com/help/us/groups/groups-32.html
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://g
roups.yahoo.com/group/perl-beginner/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http
://groups.yahoo.com/group/perl-beginner/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:perl-beginner-digest@yahoogroups.com
mailto:perl-beginner-fullfeatured@yahoogroups.com
<*> To unsubscribe from this group, send an email to:
perl-beginner-unsubscribe@yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.c
om/info/terms/
|