Loading ...
Sorry, an error occurred while loading the content.

Re: [PBML] Eporter.pm as_heavy()

Expand Messages
  • Hans Ginzel
    ... I got it: sub a { warn join t , caller(0); b(); } sub b { warn join t , caller(0); warn join t , caller(1); } *c = &a; c() The caller(1) at b()
    Message 1 of 2 , Dec 3, 2003
    • 0 Attachment
      On Tue, Dec 02, 2003 at 06:42:16PM +0100, Hans Ginzel wrote:
      > Can you make a small demo, when (caller(1))[3] "does not work"?
      >
      > sub as_heavy {
      > require Exporter::Heavy;
      > # Unfortunately, this does not work if the caller is aliased as *name = \&foo
      > # Thus the need to create a lot of identical subroutines
      > my $c = (caller(1))[3];
      > $c =~ s/.*:://;
      > \&{"Exporter::Heavy::heavy_$c"};
      > }
      >
      > # Unfortunately, caller(1)[3] "does not work" if the caller is aliased as
      > # *name = \&foo. Thus the need to create a lot of identical subroutines
      > # Otherwise we could have aliased them to export().
      >
      > sub export_tags {
      > goto &{as_heavy()};
      > }

      I got it:


      sub a {
      warn join "\t", caller(0);
      b();
      }

      sub b {
      warn join "\t", caller(0);
      warn join "\t", caller(1);
      }

      *c = \&a;
      c()

      The caller(1) at b() returns "main::a" though c() is called.


      Best regards

      Hans Ginzel
    Your message has been successfully submitted and would be delivered to recipients shortly.