regex - Perl: suppress output of backtick when file not found -


in code :

$status = `ls -l error*`; 

it shows output : ls *error no such file or directory. how can suppress message. interested in determining error files generated or not. if yes, need list of files else ignore (without printing message)

by running like

$status = `ls -l error* 2> /dev/null`; 

and suppressing external command's output standard error.

if need file names (and not other info ls's -l switch gives you), can accomplished in pure perl statement like

@files = glob("error*"); if (@files == 0) {      ... there no files ... } else {      ... files ... } 

and if need other info ls -l ..., applying builtin stat function each file name can give same information.


Comments

Popular posts from this blog

mod rewrite - Using "?" when rewriting the URL -

.htaccess: Transfer name to index.php if not directory public -

Admob integration with pygame in android -