Hi Rolf,

The three things that come to my mind are unimport via no, namespace::clean (update: or namespace::autoclean or namespace::sweep), or lexically scoped pragmas via %^H/perlpragma. I haven't used any of them in a module of my own, so I can't say much more, but maybe one of them is a starting point?

Update: That was just a bit of brainstorming - I guess the first two ideas are effective at package scope, the third at lexical scope, and then of course there's dynamic scope... I guess I'm not sure what scope you're thinking about "disabling" the package at? Also, by "disabling", do you mean actually undefining the methods, or just setting a flag such that they fail when called outside of the appropriate scope (whichever one that is)? And one more thought: Do you really need to disable the packages, or is it just a "safety" measure against accidental usage outside the correct scope? I imagine that packages named IN and LIKE are unlikely to clash with other packages...

Regards,
-- Hauke D


In reply to Re: [DSL] disabling packages in Perl? (updated) by haukex
in thread [DSL] disabling packages in Perl? by LanX

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.