Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Ovid (2709)

  (email not shown publicly)
AOL IM: ovidperl (Add Buddy, Send Message)

Stuff with the Perl Foundation. A couple of patches in the Perl core. A few CPAN modules. That about sums it up.

Journal of Ovid (2709)

Thursday November 24, 2005
03:13 PM


[ #27728 ]

Once again I'm searching for a common utility module that I assume is out there. For example, I recently asked about deleting subroutines from globs. The problem here is that you can't really do it without deleting the entire glob. What needs to be done is to copy the glob slots except for the CODE slot, delete the glob, then add back the other slots. This seems like silly make-work. I'd expect there to be a module which properly abstracts this for me:

package Some::Package;
use Symbol::Glob;
# assumes current package unless specified
my $glob = Symbol::Glob->new({ name => 'foo' });

$glob->sub( sub { return 'this is a sub' });
print $Some::Package::foo; # prints 14

print $Some::Package::foo; # undefined
print $glob->sub->();      # prints 'this is a sub'

$glob->delete;             # removes entire glob

Is there something that straightforward on the CPAN? I'm not seeing it.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • I have not investigated whether it does what you want, but it's in the ballpark.

    Now, back to turkey.
  • I decided to go ahead and write this, because I'm doing a fair amount of glob munging in WWW::Mechanize::Pluggable, and it'd be nice to have it better encapsulated. It does what you asked it to do in your example, and it's available on CPAN.

    As a nice bonus, I got a chance to try the inside-out object model and Class::Std. Found it much easier to concentrate on getting the details of the glob manipulation right because I knew that the object access code was safe.

    I did find one thing I needed to do that wasn'