ghenry has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks,

I am playing with Inside-Out Classes and trying to do Inheritance, but not sure how to use hash-references within Objects of a Inside-Out class. An example class like so:

package Samba::LDAP; use version; $VERSION = qv('0.0.1'); use warnings; use strict; use Carp; use Class::Std::Utils; use File::Basename; use base qw(File::Samba); { # Attributes my %config_of; # Constructor takes the path of the Samba config file sub new { my ($class, $samba) = @_; # Bless a scalar to instantiate the new object... my $new_object = bless anon_scalar(), $class; # Initialise the object's "config" attribute... $config_of{ident $new_object} = $samba; return $new_object; } sub get_path { my ($self) = @_; return $config_of{ident $self}; } sub get_filename { my ($self) = @_; my $filename = basename($config_of{ident $self}); return $filename; } } 1;
And the client code I've written is like so:
use strict; use warnings; use Samba::LDAP; my $smbconf = Samba::LDAP->new(q{/etc/samba/smb.conf}); # path is loaded my $path = $smbconf->get_path(); print "$path\n"; my $filename = $smbconf->get_filename(); print "$filename\n"; my @shares = $smbconf->listShares(); print "@shares\n";

No you can see my problem, listShares(); is part of File::Samba, which is hash based. My program output is:

[ghenry@perlbox lib]$ perl ../scripts/ /etc/samba/smb.conf smb.conf Not a HASH reference at /usr/lib/perl5/site_perl/5.8.6/File/ l +ine 181.
So the listShares method of File::Samba expects the object to be a hash reference. How can I provide this?

Thanks and feel free to give me a slap if this is something trivial! ;-)


Walking the road to enlightenment... I found a penguin and a camel on the way.....
Fancy a Just ask!!!

2005-11-16 Retitled by planetscape, as per Monastery guidelines
Original title: 'How to use Inheritance with Inside-Out Classes and Hash Bassed Classes'