RosettaCodeData/Task/Break-OO-privacy/Perl/break-oo-privacy.pl
2023-07-01 13:44:08 -04: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};