Guest User

Untitled

a guest
Jun 18th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. package TutorialConfig;
  2.  
  3. sub new {
  4. my ($class_name) = @_;
  5.  
  6. my $self = {};
  7. warn "We just created our new variable...\n";
  8.  
  9. bless ($self, $class_name);
  10. warn "and now it's a $class_name object!\n";
  11.  
  12. $self->{_created} = 1;
  13. return $self;
  14. }
  15.  
  16. sub fetch {
  17. my ($self,$key) = @_;
  18. return $self->{$key};
  19. }
  20.  
  21. sub store {
  22. my ($self, $key, $value) = @_;
  23. $self->{$key} = $value;
  24. }
  25.  
  26. 1;
  27.  
  28. -------------------------------------------
  29.  
  30. use 5.010;
  31.  
  32. use TutorialConfig
  33. my $thing = TutorialConfig->new(); #<- $thing is undefined after calling this.
  34.  
  35. $thing->store("author","Afton");
  36. $thing->store("new_author","still afton");
  37. print $thing->fetch("author");
Add Comment
Please, Sign In to add comment