Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/local/bin/perl
- use strict;
- package Ball;
- sub new
- {
- my $class = shift;
- my $self = {
- x => shift,
- y => shift,
- inv => shift,
- };
- bless $self, $class;
- return $self;
- }
- sub get_loc
- {
- my ($self) = @_;
- open my $locs, "<", "locations.txt";
- while ( my $line = <$locs> )
- {
- chomp($line);
- my @land = split ( /: /, $line); #two elements: the name, and the data
- my @data = split ( /,/, @land[1]); #@data=(x,y)
- return @land[0] if ( $self->{x} eq @data[0] and $self->{y} eq @data[1] );
- }
- return "Unknown";
- }
- sub print_inv
- {
- my ($self) = @_;
- print "You have: ".join(", ", @{$self->{inv}}), "\n";
- }
- 1;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement