bichonfrise74 has asked for the wisdom of the Perl Monks concerning the following question:
And below is the script that would print the standard error when I call the Check_File subroutine from the test module. So, if the "/tmp/hello.txt" does not exists, then it will give a standard error output. This is what I want to capture and save in a file.package test; use strict; sub Check_File { my $file = `ls -l /tmp/hello.txt > /tmp/result.txt`; } 1
Any comments are appreciated. Thanks.#!/usr/bin/perl use strict; use test; print "Start of print.\n"; open( STDERR, ">", "/tmp/error.txt" ) or die "Error: Cannot open file - $!"; test->Check_File(); close( STDERR ); print "End of print.\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Saving Standard Error
by jrsimmon (Hermit) on Aug 06, 2009 at 18:59 UTC | |
by bichonfrise74 (Vicar) on Aug 06, 2009 at 19:45 UTC | |
by jrsimmon (Hermit) on Aug 06, 2009 at 19:56 UTC | |
|
Re: Saving Standard Error
by tokpela (Chaplain) on Aug 06, 2009 at 19:58 UTC |