Does this mean I have to implement module called 'slice' and then implement the unimport method. Is that what you meant ? I haven't done 'no'-module !

I meant no Slicer 'SomeModule';, so you would create an unimport function instead of of unslice.

The constant will override the Slicer.pm definition

It will do that even if slice has no prototype. I notice you get a warning when you override, and two if there's a prototype mismatch, so may I suggest

use if $ENV{SLICE}, 'Slicer'; use if !$ENV{SLICE}, 'constant', slice => 0;

or better yet, move that logic into Slicer:

package Slicer; use base Exporter; our @EXPORT = qw( slice ); sub _slice { my @caller = caller; print $caller[0]; print ":: sliced :" , @_; return 1; } if ($ENV{SLICE}) { *slice = \&_slice; } else { require constant; import constant slice => 0; } 1;

Update: Nevermind, still doesn't work for slice(...). You really should use two functions instead of requiring people to use &.

package Slicer; use base Exporter; our @EXPORT = qw( slice sliced ); use constant slice => $ENV{SLICE}; sub sliced { return unless slice; my @caller = caller; print $caller[0]; print ":: sliced :" , @_; } 1;
>set SLICE= >perl -wle"use Slicer; print('!') if slice; >perl -wle"use Slicer; sliced('!'); >set SLICE=1 >perl -wle"use Slicer; print('!') if slice; ! >perl -wle"use Slicer; sliced('!'); main:: sliced :!

In reply to Re^3: Cheaper - Debug,Log,Errors via Slicing&dicing by ikegami
in thread Cheaper - Debug,Log,Errors via Slicing&dicing by rootcho

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.