package Tools; sub new { my ($caller, %args) = @_; my $caller_is_obj = ref($caller); my $class = $caller_is_obj || $caller; my $self = bless [], $class; return $self; } sub DIRUtil { my $self = shift; my ($path, $dirname, $option) = @_; if ($option eq "-c") { print $path."\n"; chdir($path) or die "$!"; mkdir ("xxx") or die "$!"; } } #### package Agent my $Utils = new Tools; sub new { my ($caller, %args) = @_; my $caller_is_obj = ref($caller); my $class = $caller_is_obj || $caller; my $self = bless [], $class; return $self; } sub checkPackage { my $this = shift; my $package = "SB"; opendir(DIR, "D:/\box/\/\somthing/\SB") or $Utils->DIRUtil( "D:\/box\/something", "SB", "-c"); } #### $agent->checkPackage();