Created
January 1, 2013 18:35
-
-
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?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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