Naghaveer R
Naghaveer R

Reputation: 2944

Error: perl Script is running twice

I have written a small script from which I'm calling another script. Code: package.PL

use strict;
no warnings 'experimental::smartmatch';
use feature qw(switch);
print"\nPlease enter Perl Installation Path\n";
my $path=<>;
$path=~ s/^\s+|\s+$//;

while(1){
            print "\nEnter your Choice : \n";
            print "1.Premigration Script for active records\n";
            print "2.Premigration Script for archival records\n";
            print "3.Post Migration Script\n";
            print "4.Cleanup Script\n";
            print "5.Exit\n";
            my $input=<>;
            given($input){
              when(1) {system("$path/perl export_from_ddts.pl configfile_active.ini");system("$path/perl convert_to_csv.pl configfile_active.ini");}
              when(2) {system("$path/perl export_from_ddts.pl configfile_archived.ini");system("$path/perl convert_to_csv.pl configfile_archived.ini");}
              when(3) {system("$path/perl post_migration.pl configfile_active.ini");}
              when(4) { system("$path/perl cleanup.pl");}
              default {
                          if($input > 4){
                            print "\nYou want to exit the menu? y/n\n";
                            my $state=<>;
                            $state =~ s/^\s+|\s+$//g ;
                          if($state eq 'y'){
                            last;
                            }
                          else{
                            continue;
                        }
                    } 
                }
            }
}

If I call any script from Package.pl, It is running twice. For example: If I select option 1 to run pre-migration script for active projects, I'm getting same output twice.

perl version:5.18.1 I'm running on another perl installation(not system perl) in linux.

Upvotes: 0

Views: 458

Answers (1)

user1558455
user1558455

Reputation:

At first you could use $^X for the PATH of Perl or $EXECUTABLE_NAME when you use use English

You see the output twice? - Your code is ok. Why do you use no warnings 'experimental::smartmatch when you don use any smartmatch operators?

I have tried to reconstruct your code but its working for me.

Upvotes: 2

Related Questions