Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^2: Overriding caller everywhere (BEGIN)

by Sartak (Hermit)
on Aug 07, 2007 at 00:45 UTC ( [id://630933] : note . print w/replies, xml ) Need Help??


in reply to Re: Overriding caller everywhere (BEGIN)
in thread Overriding caller everywhere

Doing it in a BEGIN block does seem to work in this example. But why does the identical glob test work without BEGIN? :)

Replies are listed 'Best First'.
Re^3: Overriding caller everywhere (glob)
by tye (Sage) on Aug 07, 2007 at 01:42 UTC

    Overriding of glob is special-cased. Instead of changing things so that Perl code is compiled to call your replacement routine "directly", the built-in &CORE::glob is still called and it notices (at run-time) the override and calls your replacement routine (and passes an extra argument that provides the context so that your replacement can correctly handle repeated calls made in scalar context). So you can't use CORE::glob("foo") to bypass this override (and you can't change the prototype of glob like you can with other overridden built-ins when using a recent version of Perl).

    - tye