http://www.perlmonks.org?node_id=712547


in reply to Re: Perl Inheritance & module variables
in thread Perl Inheritance & module variables

Well that does what I want but I really hate having to turn off the strict refs... I think I would prefer to just copy the data into the instance and deal it with that way unless there is a lot of data i need to copy or its time sensitive. Unless there is a better way of doing it, I think I might just keep that in my back pocket for when I really do need it.

Thanks a bunch

  • Comment on Re^2: Perl Inheritance & module variables

Replies are listed 'Best First'.
Re^3: Perl Inheritance & module variables
by gone2015 (Deacon) on Sep 20, 2008 at 08:53 UTC

    Wishing to maintain "strict refs purity" is entirely commendable :-)

    For completeness, however, I'll point out that the 'no strict'-ness is scoped within the current block. So the unpleasantness is contained. In the code I gave the the nastiness was enclosed in a subroutine. If it's necessary to do this in 'open code' you can always:

    { no strict 'refs' ; .... # unspeakable stuff redacted } ;
    to avoid contagion

    Anyway, I think that with a small penance, in the form, say, of an explanatory comment, one can forgive oneself this particular sin -- provided it doesn't become a habit :-)