Skip to content

Instantly share code, notes, and snippets.

@ChimeraCoder
Created March 30, 2011 23:10
Show Gist options
  • Save ChimeraCoder/895497 to your computer and use it in GitHub Desktop.
Save ChimeraCoder/895497 to your computer and use it in GitHub Desktop.
sub new {
my ($class) = @_;
my @owned_files = ();
#The 'shared' files are the files that a user can read but does not own
my @shared_files = ();
my $self = {
#$[0] is the class
_name => $_[1],
_owned_files => \[],
_shared_files => \[],
};
bless $self, $class;
return $self;
}
#Add a file to the list of files that a user owns
sub addOwnedFile {
my ($self, $file) = @_;
my $ref = $self -> {_owned_files};
my @array = @$ref;
push(@array, $file);
push(@array, "dude");
push(@{$self->{_owned_files}}, "blahhhhhhhhhhh");
$self->{_owned_files} = \@array;
}
sub printAll {
my $self = $_[0];
#get array values
my $result = $self->{_name} . ";";
my $ref = $self -> {_owned_files};
my @arrayOwn = @$ref;
my $ref2 = $self -> {_shared_files};
my @arrayShare = @$ref2;
my $test_doc = new DocFile("testFilename", $self);
$self->addOwnedFile("woooohooooooooo", );
$self->addSharedFile($test_doc);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment