Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

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'

In reply to How to use Inheritance with Inside-Out Classes and Hash Based Classes by ghenry

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others examining the Monastery: (10)
    As of 2018-05-28 08:48 GMT
    Find Nodes?
      Voting Booth?