All pastes #386513 Raw Edit

Stuff

public text v1 · immutable
·published 2007-03-08 18:00 UTC
rendered paste body
PhilTest.pm
-------------------8<-------------------------
#!/usr/bin/perl

package PhilTest;
use strict;

sub new {
    my $self  = {};
    $self->{v} = undef;
    bless($self);
    return $self;
}

sub inc {
    my $self = shift;
    $self->{v}++;
}

1;
------------------->8-------------------------

testpkg.pl
-------------------8<-------------------------
#!/usr/bin/perl

use PhilTest;

$m = new PhilTest;

$m->{v} = 1;
print "m->v = " . $m->{v} . "\n";
$m->inc();
print "m->v = " . $m->{v} . "\n";

------------------->8-------------------------

Output:
$ perl testpkg.pl
m->v = 1
m->v = 2