I deliberately chose to use CORE::GLOBAL in my specific case (despite the unless-you-know-what-you're-doing type of warnings in "Overriding Built-in Functions", Chap 11.3, the Camel Book).

Only having a vague idea of what the existing code1 looks like, I thought that, all in all, I might be better off replacing the built-ins globally. As I understand it, Exporter does only export into a specific namespace, e.g.

_____ MySystem.pm _____

package MySystem; use Exporter 'import'; @EXPORT = qw(system); sub system { print "wrapped system(): @_\n"; } 1;

_____ test.pl _____

#!/usr/bin/perl use MySystem; system "echo foo"; package SomeOtherModule; system "echo bar";

would print

$ ./test.pl wrapped system(): echo foo bar

i.e. the second call of system() is not being wrapped...

I'd rather not have to take care of such subleties (not all that sure I'm not getting myself into other subtleties this way, though... ;)

Could you elaborate on why not to use CORE:: ?

Almut

_____

1  as I mentioned in Using literal Japanese filenames in legacy CP932 encoding with system(), etc., the idea behind writing a jperl compatibility module is that the large number of existing scripts wouldn't need to be touched


In reply to Re^2: Wrapping the open() built-in by almut
in thread Wrapping the open() built-in by almut

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.