Next | Hook::LexWrap | 12 |
How does Hook::LexWrap make itself invisible to caller?
Easy: It throws away the real caller and replaces it with its own version
*CORE::GLOBAL::caller = sub { my ($height) = ($_[0]||0); my $i=1; my $name_cache; while (1) { my @caller = CORE::caller($i++) or return; $caller[3] = $name_cache if $name_cache; $name_cache = $caller[0] eq 'Hook::LexWrap' ? $caller[3] : ''; next if $name_cache || $height-- != 0; return wantarray ? @_ ? @caller : @caller[0..2] : $caller[0]; } };
Assigning to *CORE::GLOBAL::caller replaces the built-in caller
Calling CORE::caller invokes the built-in caller anyway
Next | Copyright © 2003 M. J. Dominus |