Created
June 15, 2012 07:42
-
-
Save alecchen/2935250 to your computer and use it in GitHub Desktop.
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
#--------------------------------------------------------------------------- | |
# Foo | |
#--------------------------------------------------------------------------- | |
package Foo; | |
use Moose; | |
has 'name' => ( is => 'rw', isa => 'Str' ); | |
sub hello { | |
my $self = shift; | |
print $self->name, "\n"; | |
} | |
#--------------------------------------------------------------------------- | |
# Bar | |
#--------------------------------------------------------------------------- | |
package Bar; | |
sub new { | |
my ($class, %args) = @_; | |
my $self = bless \%args, $class; | |
return $self; | |
} | |
sub name { | |
my ($self, $new_value) = @_; | |
$self->{name} = $new_value if $new_value; | |
return $self->{name}; | |
} | |
sub hello { | |
my $self = shift; | |
print $self->name, "\n"; | |
} | |
1; | |
#--------------------------------------------------------------------------- | |
# main | |
#--------------------------------------------------------------------------- | |
package main; | |
my $foo = Foo->new(name => 'FOO'); | |
$foo->hello; | |
my $bar = Bar->new(name => 'BAR'); | |
$bar->hello; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment