RosettaCodeData/Task/Break-OO-privacy/Perl/break-oo-privacy.pl
2015-11-18 06:14:39 +00:00

15 lines
269 B
Perl

package Foo;
sub new {
my $class = shift;
my $self = { _bar => 'I am ostensibly private' };
return bless $self, $class;
}
sub get_bar {
my $self = shift;
return $self->{_bar};
}
package main;
my $foo = Foo->new();
print "$_\n" for $foo->get_bar(), $foo->{_bar};