Check out perlfaq8 . If you do not like if it is STDOUT or STDERR , you can redirect both to STDOUT .
$output = `$cmd 2>&1`;
In your case, you probably just want to get rid of STDERR :
$output = `$cmd 2>/dev/null`;
However, I agree with the DVK answer. Using an external command to get a list of files just seems silly. You should use File :: Find . That way, you can use normal Perl error handling if something fails.
#!/usr/bin/perl use strict; use warnings; use File::Find; my @importlog; my @errorlog; find(sub { push @importlog, $File::Find::name if /^import-log\.*/; push @errorlog, $File::Find::name if /^error-log\.*/; }, '.'); print "Import log:\n", join("\n", @importlog), "\n"; print "Error log:\n", join("\n", @errorlog), "\n";
Leonardo Herrera
source share