package main; use strict; use Data::Dumper; open F, "; close F; foreach my $dir (@builds) {   chomp $dir;   my $build = MyPackage->new($dir);     print Dumper($build);   $build->scan_resultfiles();   print Dumper($build); } package MyPackage; use strict; use File::Basename; use File::Spec; use Cwd; sub new { my $proto  = shift; my $class  = ref ($proto) || $proto; my $ptr    = {}; bless ($ptr, $class); $ptr->init(@_); return $ptr; } sub init($$) {   my ($this, $path) = @_;     $this->{root} = $path;   opendir DIR, File::Spec->catdir($path, qw(lint\msg));   @{$this->{errorfiles}->{lint}} = grep /\.txt$/, readdir DIR;   closedir DIR; } sub scan_resultfiles($) {   my $this = shift;   foreach (@{$this->{errorfiles}->{lint}})   {      $this->parse_file(File::Spec->catfile(File::Spec->catdir($this->{root}, qw(lint\msg)), $_));   } } sub parse_file($$) {   my ($this, $errfile) = @_;     open FILE, "<$errfile" || die qq($!);     while ()   {      chomp;      # ...   }   close FILE;   } 1;