Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package TutorialConfig;
- sub new {
- my ($class_name) = @_;
- my $self = {};
- warn "We just created our new variable...\n";
- bless ($self, $class_name);
- warn "and now it's a $class_name object!\n";
- $self->{_created} = 1;
- return $self;
- }
- sub fetch {
- my ($self,$key) = @_;
- return $self->{$key};
- }
- sub store {
- my ($self, $key, $value) = @_;
- $self->{$key} = $value;
- }
- 1;
- -------------------------------------------
- use 5.010;
- use TutorialConfig
- my $thing = TutorialConfig->new(); #<- $thing is undefined after calling this.
- $thing->store("author","Afton");
- $thing->store("new_author","still afton");
- print $thing->fetch("author");
Add Comment
Please, Sign In to add comment