in reply to How to pass file paths in a master script which is used to run several perl scripts?

Again, you didn't post the error message:

Global symbol "$cmd1" requires explicit package name at d:/pm/gui_calc +i.pl line 3.

You have use strict; but don't define $cmd1. strict, system.

  • Comment on Re: How to pass file paths in a master script which is used to run several perl scripts?
  • Select or Download Code

Replies are listed 'Best First'.
Re^2: How to pass file paths in a master script which is used to run several perl scripts?
by ankit.tayal560 (Beadle) on Oct 18, 2016 at 09:48 UTC

    Hi marto, Yes I Know that and that exactly is my doubt. I've defined $cmd1 in my Master script as u can see above in my code and I am trying to run my gui_calci script through master script. If I have 50 Scripts I need to run through a master script and each of those scripts contain a filepath, I want to pass all those file paths from master script or someway or another from outside because it is very difficuilt to modify filepaths in 50 scripts everytime . Any suggestions would help? P.S. Apologies for not posting the error message

      It doesn't work this way. In the master script you define your variables, however you run another perl script via system. It knows nothing about the variables in the master script. Consider the following example: master.pl

      #!/usr/bin/perl use strict; use warnings; my $secret = 'BruceWayneisBatman'; my @cmd = ('perl', 'child.pl', $secret); system(@cmd) == 0 or die "system @cmd failed: $?";

      child.pl

      #!/usr/bin/perl use strict; use warnings; my $message = $ARGV[0]; print "The master script passed: $message\n";

      Again see system.

        Nothing technically wrong with this, just a remark/reminder.

        Passing a secret via the command line exposes the secret in the process list. Everybody with access to 'ps' or /proc/<pid>/cmdline can see the secret. (This may include some totally unrelated piece of software which logs the contents of 'ps -ef' for debugging/troubleshooting purposes.)

        Yes, this is kinda obvious, but I wanted to put attention to it anyway.