Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

use parent qw( Tie::StdArray)

by rlauer (Novice)
on Oct 28, 2022 at 17:59 UTC ( [id://11147793]=perlquestion: print w/replies, xml ) Need Help??

rlauer has asked for the wisdom of the Perl Monks concerning the following question:

Good day Monks! I seek some wisdom as I try to "do things the right way" perlcritic doesn't like when we use @ISA explicitly...but this dog don't hunt:

use Tie::Array; use parent qw(Tie::StdArray);

I realize that Tie::StdArray is a module within Tie::StdArray so:

use parent qw(Tie::StdArray);

...doesn't hunt either... ...am I relegated to:

use vars qw(@ISA); @ISA = qw (Tie::StdArray); ## no critic (ProhibitExplicitISA)

???? - I know that perlcritic isn't always spot on, but before I ## no critic this chunk I will attempt to be enlightened. Thanks for shining some light on an otherwise dark room

Replies are listed 'Best First'.
Re: use parent qw( Tie::StdArray)
by haj (Vicar) on Oct 28, 2022 at 18:42 UTC

    I guess you're looking for the -norequire switch which allows to define a parent relationship without causing Perl to look for the wrong module:

    package My::Array { use Tie::Array; use parent -norequire, qw(Tie::StdArray); }
Re: use parent qw( Tie::StdArray)
by pryrt (Abbot) on Oct 28, 2022 at 18:36 UTC
    dog don't hunt

    I assume you mean "it gave me an error that it couldn't locate Tie/StdArray.pm in @INC". Sharing error messages helps us to help you better than any variant of the phrase "it doesn't work".

    parent shows an example of how to have a parent of Tie::StdHash. Did you try to use that same pattern with Tie::StdArray? Because using -norequire option worked for me.

    C:\usr\local\share > perl -MTie::Array -le "use parent qw(Tie::StdArray)" Can't locate Tie/StdArray.pm in @INC (you may need to install the Tie: +:StdArray module) (@INC contains: ...) BEGIN failed--compilation aborted at -e line 1. C:\usr\local\share > perl -MTie::Array -le "use parent -norequire => 'Tie::StdArray'"

      Thanks to the Monks for shedding light on this issue. I will study the docs on parent...thanks again.</P

Re: use parent qw( Tie::StdArray)
by afoken (Chancellor) on Oct 29, 2022 at 12:00 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://11147793]
Approved by LanX
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2024-04-19 21:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found