Author: techfox9
Perl basic class definition and usage example..
Tuesday, October 7th, 2008 @ 12:09 pm
#!/usr/bin/perl use strict; { package SomeClass; sub new { my $class = shift; my $self = { v1 => undef, v2 => undef, }; bless($self, $class); return $self; } sub setV1($) { my $self = shift; if (@_) { $self->{v1} = shift } return $self->{v1}; } sub getV1() { my $self = shift; return $self->{v1}; } } main(); sub main() { my $foo = SomeClass->new(); $foo->setV1(38); print $foo->getV1() . "\n"; }