Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It seems to me, you are mixing up two things here: Object-Oriented and Procedural Perl. Perl OO is kind of "different" (as in not mainstream but workable).</p> <p>Your TestBase.pm module seems to expect to be run as a Perl object (Perl oo-style), but your Perl script wants to access it as "normal" module. Perl doesn't work the way C++ does (as you realised) so you would have to construct your code differently. See Damian Conway's books for explanations (and smarter code than mine below).</p> <hr> <p><strong>Procedural:</strong></p> <pre><code>#! /usr/bin/perl #The module to inherit from package TestBase; use strict; use warnings; use Exporter (); our @ISA = qw (Exporter); our @EXPORT = qw (tbSub); #------------------------------- sub tbSub { my ($parm) = @_; print "\nTestBase: $parm\n"; } 1; </code></pre> <p>.</p> <pre><code>#! /usr/bin/perl #The descendent class use strict; use warnings; use TestBase; sub main; sub mySub; #------------------------------- #Entry point... main(); #---code------------------------ sub main { mySub(1); tbSub(2); mySub(3); } #------------------------------- sub mySub { my $parm = shift; print "\nTester: $parm\n"; } </code></pre> <hr> <p><strong>Perl OO</strong></p> <pre><code>#! /usr/bin/perl #The base class to inherit from package TestBase; use strict; use warnings; #------------------------------- sub new { my $s={ }; return bless $s; } sub tbSub { my ($self,$parm) = @_; print "\nTestBase: $parm\n"; } 1; </code></pre> <p>.</p> <pre><code>#! /usr/bin/perl #The descendent class use strict; use warnings; use TestBase; sub main; sub mySub; #------------------------------- #Entry point... main(); #---code------------------------ sub main { my $tb = TestBase-&gt;new(); mySub(1); $tb-&gt;tbSub(2); mySub(3); } #------------------------------- sub mySub { my $parm = shift; print "\nTester: $parm\n"; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload