Skip to content

Instantly share code, notes, and snippets.

@pdl
Created January 1, 2013 18:35
Show Gist options
  • Save pdl/4429233 to your computer and use it in GitHub Desktop.
Save pdl/4429233 to your computer and use it in GitHub Desktop.
Is there a perl module that allows inheritance like a compile-time modifiable symbol table?
use strict;
use warnings;
use 5.010;
{
package A;
our $hash={1=>'i',2=>'j'};
}
{
package B;
use base 'A';
our $hash = {%{$A::hash}};
$hash->{2}='ii';
$hash->{3}='iii';
}
use Data::Dumper;
$A::hash->{1}='I';
print Dumper $A::hash; # WANT: { '1' => 'I', '2' => 'j' };
print Dumper $B::hash; # WANT: { '1' => 'I', '2' => 'ii', '3' => 'iii'};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment