in reply to Re: Re: Script which creates 2nd script and runs it
in thread Script which creates 2nd script and runs it

You're using system to execute a shell script which then executes other commands. My suggestion is skipping the shell script altogether, and using system to execute those commands directly from Perl.

For example:

foreach $key (keys %hash) { my $cmd = "$program $key $matrix "; $cmd .= "$path/CISCO_$_.clean " for @{$hash{$key}}; system($cmd) == 0 # system returns 0 on success or die "system '$cmd' failed: $?"; }