Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^2: Wrapping the open() built-in

by almut (Canon)
on Oct 27, 2006 at 15:37 UTC ( [id://580940]=note: print w/replies, xml ) Need Help??


in reply to Re: Wrapping the open() built-in
in thread Wrapping the open() built-in

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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://580940]
help
Chatterbox?
and the web crawler heard nothing...

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

    No recent polls found