We help IT Professionals succeed at work.
Get Started

Perl Script Problem.

new_perl_user
on
426 Views
Last Modified: 2012-05-10
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: $?";

   }
}




Comment
Watch Question
CERTIFIED EXPERT
Commented:
This problem has been solved!
Unlock 1 Answer and 6 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE