#!/usr/local/bin/perl use strict; use warnings; package Test1; sub new { my $class = shift; my $self = { _txt => shift }; bless $self, $class; return $self; } sub _sub1() { #private method my $self = shift; $self->{_txt} = "bar"; return $self->{_txt}; } sub sub2() { #public method _sub1(); } sub getTxt() { my ($self) = @_; return $self->{_txt}; } 1;