<?xml version="1.0" encoding="windows-1252"?>
<node id="508694" title="How to use Inheritance with Inside-Out Classes and Hash Based Classes" created="2005-11-15 12:06:29" updated="2005-11-15 07:06:29">
<type id="115">
perlquestion</type>
<author id="386673">
ghenry</author>
<data>
<field name="doctext">
&lt;p&gt;Dear Monks,&lt;/p&gt;
&lt;p&gt;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:
&lt;readmore&gt;
&lt;c&gt;
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;
&lt;/c&gt;
And the client code I've written is like so:
&lt;c&gt;
use strict;
use warnings;
use Samba::LDAP;

my $smbconf = Samba::LDAP-&gt;new(q{/etc/samba/smb.conf});

# path is loaded
my $path = $smbconf-&gt;get_path();
print "$path\n";

my $filename = $smbconf-&gt;get_filename();
print "$filename\n";

my @shares = $smbconf-&gt;listShares();
print "@shares\n";
&lt;/c&gt;
&lt;/p&gt;
&lt;p&gt;No you can see my problem, &lt;c&gt;listShares();&lt;/c&gt; is part of &lt;c&gt;File::Samba&lt;/c&gt;, which is hash based. My program output is:
&lt;c&gt;
[ghenry@perlbox lib]$ perl ../scripts/test.pl
/etc/samba/smb.conf
smb.conf
Not a HASH reference at /usr/lib/perl5/site_perl/5.8.6/File/Samba.pm line 181.
&lt;/c&gt;
So the &lt;c&gt;listShares&lt;/c&gt; method of &lt;c&gt;File::Samba&lt;/c&gt; expects the object to be a hash reference. How can I provide this?
&lt;/p&gt;
&lt;/readmore&gt;
&lt;p&gt;Thanks and feel free to give me a slap if this is something trivial! ;-)&lt;/p&gt;
&lt;p&gt;Gavin.&lt;/p&gt;
&lt;div class="pmsig"&gt;&lt;div class="pmsig-386673"&gt;
&lt;small&gt;Walking the road to enlightenment... I found a penguin and a camel on the way.....&lt;br/&gt;
Fancy a yourname@perl.me.uk? Just ask!!!&lt;/small&gt;
&lt;/div&gt;&lt;/div&gt;&lt;p&gt;&lt;small&gt;2005-11-16 Retitled by [planetscape], as per Monastery [id://341118|guidelines] &lt;br /&gt;Original title: 'How to use Inheritance with Inside-Out Classes and Hash Bassed Classes'&lt;/small&gt;&lt;/p&gt;</field>
</data>
</node>
