Hi,
The below Perl Script reads directories and sub directories recursively and process the image files in them by calling another application.
The problem is I am calling this Perl Script from another Perl script. It is being invoked and it is processing all the images but after completion of all the image processing it is not exiting the script.
I mean it is looping again and processing the images from first rather than calling the next script in line.
#!/usr/local/bin/perl-w
use File::Find;
use XML::Simple;
use File::Basename;
# Get the directory from the command line or use the default directory
$search = shift || '/usr/qa/files' ;
#!/usr/local/bin/perl-w
use File::Find;
use XML::Simple;
use File::Basename;
# Get the directory from the command line or use the default directory
$search = shift || '/usr/qa/files' ;
# Get an array of all subdirectories
find sub { push @dirs, $File::Find::name if -d }, $search ;
for $dir ( @dirs ) {
opendir $dh, $dir or do { warn "Cannot open '$dir' $!" ; next ; } ;
opendir( DIR, "$dir" );
@files = grep( /\.jpg$/, readdir( DIR ) ) ;
closedir( DIR ) ;
(my $logdir = $dir)=~s|^\Q$search/\E||i;
$logdir =~ s|/IMAGES$||i;
$logdir = "/usr/qalogs/$logdir/FITS";
mkdir $logdir;
foreach $file ( @files ) {
print "$dir/$file\n" ;
$logfilename =$file;
$logfilename =~s/\.jpg$/.xml/;
@args = ("/usr/qa/fits-0.4.2/fits.sh", "-i", "$dir/$file","/usr/qa/fits-0.4.2/fits.sh", "-o", "$logdir/$logfilename");
system( @args ) == 0 or die "system @args failed: $?";
}
}