Calling Perl Scripts from a Perl script given the scripts are in an array -


i have list of perl scripts sample_1.pl , sample_2.pl & sample_3.pl. stored in array

my @scripts (      sample_1 => "this script number 1 ",      sample_2 => "this script number 2 ",      sample_3 => "this script number 3 " ) 

now how call these scripts using foreach loop

firstly, it's not clear whether want store commands in array or hash. 2 data structures different in perl. in code, store commands in array (@scripts) initialise array using hash-like syntax ((key => value, ...)). syntax work, doesn't (i think!) want do. end keys in array, , it's hard skip them.

if want store commands in array, this:

my @scripts = (   "this script number 1 ",   "this script number 2 ",   "this script number 3 " );  system($_) @scripts; 

if want store them in hash reason, store them in has , use hash function values want.

my %scripts = ( # %, not @ hash   sample_1 => "this script number 1 ",   sample_2 => "this script number 2 ",   sample_3 => "this script number 3 " );  system($_) values %scripts; 

but note hashes un-ordered, won't able control order in commands executed.


Comments

Popular posts from this blog

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -