#!/usr/bin/perl -w use strict; use File::Find; find(\&wanted,'/root/data'); sub wanted { if ($_=~ /^CPU-MEM/){ chdir($_); my $dir=cwd(); my @files=<$dir/*>; my $count=@files; if($count<4){ system('/usr/bin/perl /root/scripts/a.pl'); system('/usr/bin/perl /root/scripts/b.pl'); } chdir(".."); } } #### dir3 dir1 dir2