Well I'm not sure what snippet would work. This is running a set of scripts (total of about 8 to run this example) that are using objects to set up the environment depending on platform and OS. I already have some warnings placed in the code, as well as print statements for debugging.

The basic function is this:

sub getBinDir { my $self = shift; if ( not exists $self->{'binDir'} ) { warn "Object member binDir not set"; return ""; } $self->{'binDir'} = shift if @_; print "Returning binDir.\n"; return $self->{'binDir'}; }

It's located in the TestHarness.pm file, but called from UnixTestHarness.pm

sub copyCtestBinaries { my $self = shift; my $binDir = $self->getBinDir(); if ( $binDir eq '' ) { warn "Could not set up C test binary area: $!\n"; print "Received " . $self->getBinDir() . " for binDir.\n"; return; } $binDir = $binDir . "\/*"; print "BinDir = $binDir.\n"; my $appBin = $self->app1() . "/bin"; print "AppDir = $appBin.\n"; `cp $binDir $appBin`; }

With the values set up in SolarisTestHarness.pm

sub new { my $class = shift; # Pass the command line to the base class. my $self = $class->SUPER::new(@_); # Set OS specific defaults. $self->{'binDir'} = 'bin/solaris'; bless ($self, $class); return $self; }

One thing I did try, was to move the function to the SolarisTestHarness.pm file and set it there if its not set already. Which generated the following:
Can't locate object method "getBinDir" via package "SolarisTestHarness" at /opt/testharness/UnixTestHarness.pm line 90.


In reply to Re^4: Question on OO Perl by gokuraku
in thread Question on OO Perl by gokuraku

Title:
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, details, 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, summary, 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.