steph_bow has asked for the wisdom of the Perl Monks concerning the following question:

UPDATE3 : SORRY, I HAVE JUST REALISED THAT THE FILES EXIST, EXCEPT THEY ARE IN SOME CHILD DIRECTORIES. SO THERE IS NO PROBLEM ANY MORE.

Hello Deak Monks

I would like to get the errors which concern a certain script (here prog2.pl) in my program, which is composed of several scripts, like:

my $cmd1 = "perl prog1.pl"; system($cmd1); my $cmd2 = "perl prog2.pl"; system($cmd2); my $cmd3 = "perl prog3.pl"; system($cmd3);

So for the script concerned (prog2.pl for example) , I write:

BEGIN { open(STDERR, ">stderr2.log") or die "Failed to open log file"; }

Then I write

close STDERR;

So that each time I invoke my script, it write only the errors for this part. However at the end, I have nothing. Could you explain ? Thanks

update: I erased the term subscript, as it was too ambiguous. update2 : just as cdarke said, what I called "subscript" meant another script being called as a child process. Sorry for the ambiguity. UPDATE3 : SORRY, I HAVE JUST REALISED THAT THE FILES EXIST, EXCEPT THEY ARE IN SOME CHILD DIRECTORIES. SO THERE IS NO PROBLEM ANY MORE.

Replies are listed 'Best First'.
Re: get the errors only for a part of the program
by cdarke (Prior) on Apr 09, 2008 at 13:30 UTC
    Works OK for me. I tried:
    use warnings; use strict; BEGIN { open(STDERR, ">stderr2.log") or die "Failed to open log file"; } print STDERR "Oops!\n"; system ('nosuchprogram'); close STDERR;
    In stderr2.log was:
    Oops! 'nosuchprogram' is not recognized as an internal or external command, operable program or batch file.
    Running on 5.10.0 Windows.

    update: I guessed that "subscript" meant another script being called as a child process, but could be wrong.
Re: get the errors only for a part of the program
by apl (Monsignor) on Apr 09, 2008 at 13:29 UTC
    "Subscript" generally means an index into array. In  $keys[$k] = $_;, $k would be the subscript. In other words, expect a little confusion.

    You're saying that nothing gets written to STDERR? Are you certain something will be written there? It's possible your program never resulted in a condition where you would write to STDERR.

    If you could show us your code, we'd have a better chance of helping you find the problem.

Re: get the errors only for a part of the program
by Anonymous Monk on Apr 09, 2008 at 13:21 UTC
    Whats a subscript?