package test; use strict; sub Check_File { my $file = `ls -l /tmp/hello.txt > /tmp/result.txt`; } 1 #### #!/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";