Skip to content

Instantly share code, notes, and snippets.

@MicicFilip
Created March 25, 2016 10:36
Show Gist options
  • Save MicicFilip/0c293b8ac03cd12afda3 to your computer and use it in GitHub Desktop.
Save MicicFilip/0c293b8ac03cd12afda3 to your computer and use it in GitHub Desktop.
#! C:\Strawberry\perl\bin\perl.exe
use warnings;
use strict;
use v5.010;
use prvi2;
my $op1 = new Vector(2, 1, 1);
my $op2 = new Vector(5, 1, 1);
say "-";
say $op1->add($op2);
say "-";
#! C:\Strawberry\perl\bin\perl.exe
use warnings;
use strict;
use v5.010;
package Vector;
sub new {
my $class = shift;
my $self = {
_x => shift,
_y => shift,
_z => shift
};
sub add {
my ($self) = shift;
$self->{_x} += $self->{_x};
#$self->{_x}++;
return $self->{_x};
}
bless $self, $class;
return $self;
}
1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment