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

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -