My problem with bsd_glob()
See bsd_glob does not reset $!]
# This file is not there so it doesn't match and afterwards $! ist
# set. OK
my $pat2 = "this_will_miss_in_globbing";
print "\nPATT $pat2\n";
print "PRE ERR: ", Dumper($!);
@list = bsd_glob($pat2, GLOB_ERR | !GLOB_NOCHECK);
print "POST ERR: ", Dumper($!);
print "GLOB_ERROR: ", Dumper(GLOB_ERROR);
print Dumper(\@list);
print "\n";
# This file exists so the match is a success
# afterwards $! ist still set which is OK
my $pat3 = "passwords.dat";
print "\nPATT $pat3\n";
print "PRE ERR: ", Dumper($!);
@list = bsd_glob($pat3, GLOB_ERR | !GLOB_NOCHECK);
print "POST ERR: ", Dumper($!);
print "GLOB_ERROR: ", Dumper(GLOB_ERROR);
print Dumper(\@list);
print "\n";
# This resets $! back to normal ??
my $pat4 = "*.dat";
print "\nPATT $pat4\n";
print "PRE ERR: ", Dumper($!);
@list = bsd_glob($pat4, GLOB_ERR | !GLOB_NOCHECK);
print "POST ERR: ", Dumper($!);
print "GLOB_ERROR: ", Dumper(GLOB_ERROR);
print Dumper(\@list);
print "\n";
This produces the output:
PATT this_will_miss_in_globbing
PRE ERR: $VAR1 = '';
POST ERR: $VAR1 = 'No such file or directory';
GLOB_ERROR: $VAR1 = 0;
$VAR1 = [];
PATT passwords.dat
PRE ERR: $VAR1 = 'No such file or directory';
POST ERR: $VAR1 = 'No such file or directory';
GLOB_ERROR: $VAR1 = 0;
$VAR1 = [
'passwords.dat'
];
PATT *.dat
PRE ERR: $VAR1 = 'No such file or directory';
POST ERR: $VAR1 = '';
GLOB_ERROR: $VAR1 = 0;
$VAR1 = [
'DATEN_20050427210054.dat',
'passwords.dat'
];
|