steph_bow has asked for the wisdom of the Perl Monks concerning the following question:
Hello dear Monks,
I have written a code that makes some operations in several directories then gathers the results in a file
The problem is that no error is indicated but the outfile file is void. Could you check ?, thanks.
Here is a simplified version so if there are some errors, there should be minor. I believe that the problem may lie with the line where I call the child script.
use strict; BEGIN { open(STDERR, ">stderr.log") or die "Failed to open log file"; } my $slot_outfile = "results.csv"; open my $SLOT_OUTFILE, q{>}, $slot_outfile or die; my @REG_list = qw{Regulation_AZT Regulation_IOP Regulation_AERTC}; chdir(".."); chdir("ALL_WEEKS"); my $reg; my $week = "W36"; foreach $reg (@REG_list){ chdir("semaine_${week}/${reg}") or die "Can't go into the director +y $reg!"; my @SLOTS = glob("slot_list*.out"); my @SLOTS_01 = grep /(\w+).(\d\d).(01).(\w+).out/, @SLOTS; my $slot_file = $SLOTS_01[0]; my $cmd = "perl ../../../WP4_utility_analysis/WP4_utility.pl $slot +_file $SLOT_OUTFILE"; system($cmd); chdir("../.."); }
and the child program WP4_utility.pl is
use strict; BEGIN { open(STDERR, ">stderr2.log") or die "Failed to open log file"; } my $slot_file = $ARGV[0]; my $OUFTILE = $ARGV[1]; open my $SLOT_INFILE, q{<}, $slot_file; my %hash; while (my $line = <$SLOT_INFILE>) { my @Elements = split /;/, $line; $hash{$Elements[0]} = $Elements[1]; } my @Keys = keys %hash; my $key; foreach $key(@Keys){ print $OUTFILE "$key;$hash{$key}\n"; } close STDERR;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: results printing error
by apl (Monsignor) on Apr 15, 2008 at 13:26 UTC | |
|
Re: results printing error
by ww (Archbishop) on Apr 15, 2008 at 13:30 UTC | |
by steph_bow (Pilgrim) on Apr 15, 2008 at 13:50 UTC | |
|
Re: results printing error
by moritz (Cardinal) on Apr 15, 2008 at 13:27 UTC | |
|
Re: results printing error
by olus (Curate) on Apr 15, 2008 at 13:31 UTC | |
by steph_bow (Pilgrim) on Apr 15, 2008 at 13:37 UTC | |
by ww (Archbishop) on Apr 15, 2008 at 14:47 UTC | |
|
Re: results printing error
by oko1 (Deacon) on Apr 15, 2008 at 16:27 UTC |