Acme-Innuendo

 view release on metacpan or  search on metacpan

lib/Acme/Innuendo.pm  view on Meta::CPAN

package Acme::Innuendo;

use 5.006001;
use strict;
use warnings;

require Exporter::Lite;

our @ISA = qw(Exporter::Lite);

our @EXPORT_OK = ( );

our @EXPORT = qw(
  special_place nudge_nudge wink_wink walk_the_dog
);

our $VERSION = '0.03';
$VERSION = eval $VERSION;  # see L<perlmodstyle>

sub special_place {
  my $namespace = shift || 'main';
  if (defined $namespace) {
    $namespace .= '::';
  }
  no strict 'refs';
  return *$namespace;
}

sub nudge_nudge {
  my ($root, $sym, $value) = @_;
  $root->{$sym} = $value;
}

sub wink_wink {
  my ($root, $sym) = @_;
  return $root->{$sym};
}


sub walk_the_dog {
  my $root     = shift;
  my $callback = shift || sub { };

  return unless ($root);

  foreach my $sym (keys %$root) {
    my $ref = $root->{$sym};
    if ($sym =~ m/::$/)  {
      walk_the_dog($ref, $callback), if ($sym ne 'main::');
    }
    else {
      &$callback($root,$sym,$ref);
    }
  }
}


1;
__END__


=head1 NAME

Acme::Innuendo - polite access to Perl's private parts

=head1 SYNOPSIS

  use Acme::Innuendo;

  # Create an alias

  nudge_nudge( special_place(), "alias_sub",
    wink_wink( special_place(), "some_sub" )
  );

  # Walk the symbol table

  walk_the_dog( special_place(), sub {



( run in 0.523 second using v1.01-cache-2.11-cpan-d7f47b0818f )