Skip to content

Instantly share code, notes, and snippets.

@VladimirSaz
Created May 6, 2014 06:38
Show Gist options
  • Save VladimirSaz/11554475 to your computer and use it in GitHub Desktop.
Save VladimirSaz/11554475 to your computer and use it in GitHub Desktop.
PERL - simple class
package PackageName;
sub new {
my ($class, $args) = @_;
my $self = {
attr1 => $args->{attr1} || 'some_template_conent',
attr2 => $args->{attr2} || 1,
attr3 => $args->{attr3} || 1,
};
#more code here if u want
return bless $self, $class;
}
sub multiplicate {
my $self = shift;
#any code here
return $self->{attr2} * $self->{attr3};
}
###How to use:
# my $simple_usage = PackageName->new(attr1=>"example_text", attr2=>2, attr3=>4)
# my $result = $simple_usage->multiplicate()
1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment