glob_error#
Report the error status of the most recent bsd_glob call.
תקציר#
my @files = bsd_glob('~nobody', GLOB_TILDE | GLOB_ERR);
if (GLOB_ERROR) {
warn "glob failed: $!";
}
מה מוחזר#
An integer. Zero means the last bsd_glob call completed without error. A non-zero value signals that an error interrupted traversal: GLOB_NOSPACE for allocation failure, GLOB_ABEND for a stopped traversal. When non-zero, $! carries the underlying errno.
דוגמאות#
use File::Glob ':bsd_glob';
my @out = bsd_glob('/root/*', GLOB_ERR); # root-only dir
print "error\n" if GLOB_ERROR; # usually prints under non-root
מקרי קצה#
Reading
GLOB_ERRORwithout a precedingbsd_globcall returns0.Reading it after a successful call returns
0.
הבדלים מן ה-upstream#
Always returns
0. pperl does not thread per-call glob error state through the interpreter, so the value is a stub. Scripts that gate onGLOB_ERRORwill always take the no-error branch. Use$!directly if you need to detect filesystem errors during globbing. Covered byt/81-xs-native/File/Glob/*.t.
ראו גם#
bsd_glob- the call whose outcome this function reports.GLOB_ERR- the flag that makesbsd_globstop (rather than skip) on unreadable directories.GLOB_NOSPACE,GLOB_ABEND- the two non-zero values this would return upstream.