1use strict;
2use warnings;
3
4package MyClass;
5
6sub new
7{
8    my $class = shift;
9
10    my $self = bless {}, $class;
11
12    $self->_init(@_);
13
14    return $self;
15}
16
17sub _init
18{
19    my $self = shift;
20
21    $self->{foo} = 'bar';
22
23    return;
24}
25
26sub greet
27{
28    my ($self, $msg) = @_;
29
30    print "$msg - $self->{foo}\n";
31
32    return;
33}
34
351;
36
37package main;
38
39my $obj = MyClass->new;
40
41$obj->greet("Hello");
42
431;
44