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;

In reply to results printing error by steph_bow

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.