Skip Menu |

This queue is for tickets about the subs-auto CPAN distribution.

Report information
The Basics
Id: 79970
Status: open
Priority: 0/
Queue: subs-auto

People
Owner: Nobody in particular
Requestors: brianski [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 0.07
Fixed in: (no value)



I was excited to see the in => keyword to import() - I thought it would let me do this: use lang; # subs::auto->import(...) called in lang.pm bareword fiesta goes here ...; instead of this: use lang; use subs::auto; bareword fiesta goes here ...; but alas, no dice. Any chance it could be implemented? Or is the issue that we can't get at the caller's scope? Thanks for your time, Brian Szymanski
Hello, Thanks for your interest in subs::auto. If I declare this package (also attached with this ticket) : ############################### package X; use strict; use warnings; require subs::auto; sub import { shift; subs::auto->import(in => scalar caller); } 1; ############################### and load it, I get : ############################### $ perl -MO=Deparse -e 'use X; fiesta 1' use X; BEGIN { $^H{'subs::auto'} = '1'; } fiesta(1); -e syntax OK ############################### which shows that subs::auto acted on the 'main' package. Likewise, if it is loaded in another package, then the bareword is compiled into the proper package as well : ############################### $ perl5.16.1 -MO=Deparse -e 'package Y; use X; fiesta 1' package Y; sub BEGIN { require X; do { 'X'->import }; } BEGIN { $^H{'subs::auto'} = '1'; } fiesta(1); -e syntax OK ############################### Was this what you were looking for? If that's the case, make sure you're using version 0.07 of subs::auto, as the previous ones were buggy in that regard. Vincent
Subject: X.pm
package X; use strict; use warnings; require subs::auto; sub import { shift; subs::auto->import(in => scalar caller); } 1;
I'm marking this ticket as stalled due to the lack of feedback in the past 10 months.
I'm up to no good, so feel free to tell me to go away =) I'm trying to make something like the attached work. Unfortunately, subs::auto doesn't seem to do what's needed to dispatch autoloaded subs: ski@anito:/tmp/p5$ perl -le 'use X; use subs::auto; foo() ' called foo at X.pm line 17. ski@anito:/tmp/p5$ perl -le 'use X; use subs::auto; foo' Undefined subroutine &main::foo called at -e line 1
Subject: X.pm
package X; use strict; use warnings; require subs::auto; sub import { my $class = shift; no strict 'refs'; my $caller = scalar caller; *{ "${caller}::AUTOLOAD" } = sub { my $sub = ${"AUTOLOAD"}; $sub =~ s/^.*:://; warn "called $sub"; }; subs::auto->import ( in => scalar caller ); } 1;
oops, set fixed in accidentally.