Hello,

I try to fix a problem in a CPAN module: ClearCase::Argv.
This module should share a co-process running a cleartool executable, to service requests. At least in so-called ipc mode. But in my understanding, it doesn't.

ClearCase::Argv is a specialization of Argv.
My tentative changes involve adding a constructor, where there was none: the base constructor was enough—I assume.

So, here are my changes (I introduce a reference count of the objects using the same co-process. Using the same process may mean using the one set up at class level in the ipc member function, or the one used in an existing object, if performing a copy-construction. The DESTROY member also calls ipc but with a 0 argument, thus resulting in a decrement, and optional cleanup):

ClearCase-Argv> ct diff -diff -pred Argv.pm 18c18 < --- > my %pidcount; 425d424 < # Send an explicit "exit" command and close up shop. 426a426 > return 0 if --$pidcount{$self->{IPC}->{PID}}; 426a427 > # Send an explicit "exit" command and close up shop. 440c441,444 < --- > if (($self ne $class) and $class->{IPC}) { > ++$ipccount{$class->{IPC}}; > return 0; > } 616a621,634 > > # Constructor, and copy constructor as clone, with $proto > sub new { > my $proto = shift; > my $self = $proto->SUPER::new(@_); > if (ref($proto)) { > # Correct the effect of the base cloning on globs > my $down = $proto->{IPC}->{DOWN}; > $self->{IPC}->{DOWN} = $down; > my $back = $proto->{IPC}->{BACK}; > $self->{IPC}->{BACK} = $back; > ++$ipccount{$proto->{IPC}}; > } > }
When running make test, I get now:
... Can't call method "qx" without a package or object reference at test.p +l line 50.
Line 50 in test.pl is:
49: my $wdv = ClearCase::Argv->new("pwv -wdview -s"); 50: my $view = $wdv->qx;
...the first use of an object created with my new constructor... Note that this construction involved arguments.
So, I guess my construction went badly wrong.
I can anticipate an other problem: new in the base class is aliased to clone. I should probably reproduce this in the derived class. Anyway, I assume this is not the cause of the current error.

Any clue what's so wrong with my construction?
Thanks,
Marc


In reply to Constructor in derived class by cramdorgi

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.