Geoffrey Young wrote:
Or you can (simply put) "delete $Foo::Bar::{'Baz::'};". Deleting the entire stash from that package.
you're sick. sick, sick, sick.
I love it ;)
just out of curiosity, did you try deleting the special glob entries, like $Foo::Bar::Baz{CODE}?
Deleting the package's stash deletes everything in it, CODE included.
+sub module_to_package { + my $module = shift; + $module =~ s/\//::/g; + $module =~ s/\.pm$//g; + return $module; +} +
I've always wondered if this is approach is portable. that is are the keys in %INC always separated with '/' regardless of the platform? I guess nobody here has a VMS or EBCDIC machine to test with...
Yeah, I don't know about that either, but if it is a problem, we are making this sort of assumption in many places.
+void modperl_package2filename(apr_pool_t *p, const char *package,
+ char **filename, int *len)
+{
+ const char *s;
+ char *d;
+ + *filename = apr_palloc(p, (strlen(package)+4)*sizeof(char));
+ + for (s = package, d = *filename; *s; s++, d++) {
+ if (*s == ':' && s[1] == ':') {
+ *d = '/';
+ s++;
+ }
+ else {
+ *d = *s;
+ }
+ }
+ *d++ = '.';
+ *d++ = 'p';
+ *d++ = 'm';
+ *d = '\0';
+ + *len = d - *filename;
+}
I know you're just moving this from one place to another, but (again) is this portable across all platforms, assuming that '/' is the path separator?
I'd have to check Perl's insides, but I think it's a safe assumption. Win32 people might correct me here.
I took a look around APR and don't see a generic function for this kind of thing, though...
+ /* Split the package name on the last '::' */ + /* Foo::Bar::Baz */
what if you want to unload just Foo and not Foo::Bar? CGI and Digest come to mind...
I thought this was working fine, but now that I think of it, I think you just uncovered a small problem with my code ;-) Yes, deleting Foo's stash would also delete stashes of all Foo::* modules, definitely _not_ a good thing.
Just need to iterate over the package's parent stash, and wipe everything _except_ entries that end in ::. New patch will be on the way.
other than that, wicked cool!
And from the tests, it _does_ get rid of all warnings, on constants and prototypes.
Other thing I haven't quite checked yet is the effect of this on a XS package, calling bootstrap() a second time might end up 'leaking' a .so file. More on this later.
--Geoff
-- -------------------------------------------------------------------------------- Philippe M. Chiasson m/gozer\@(apache|cpan|ectoplasm)\.org/ GPG KeyID : 88C3A5A5 http://gozer.ectoplasm.org/ F9BF E0C2 480E 7680 1AE5 3631 CB32 A107 88C3A5A5
signature.asc
Description: OpenPGP digital signature