scratchpad
stefan k
<h2>My problem with <code>bsd_glob()</code></h2>
See [id://575380]]
<code>
# 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";
</code>
This produces the output:
<code>
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'
];
</code>
<p>
<table border="1" width="90%">
<tr>
<td bgcolor="000066" align="center"><font color="white"><b> Node Collection </b></font></td>
</tr>
<tr>
<td>
<BR><A HREF="http://perlmonks.org/index.pl?node_id=108959">New user scratch pad.</A><BR><A HREF="http://perlmonks.org/index.pl?node_id=17245">Number of Monks by Level</A><BR><A HREF="http://perlmonks.org/index.pl?node_id=123590">How good is Perl for AI?</A><BR><A HREF="http://perlmonks.org/index.pl?node_id=128516">Seeking a good punchline</A><BR><A HREF="http://perlmonks.org/index.pl?node_id=9523">fork...</A><BR><A HREF="http://perlmonks.org/index.pl?node_id=130140">Fun With Perl: Golf</A>
<br /><a HREF="/index.pl?node_id=212712">XS Library - Embedding C code in Perl</a>
<br /><a HREF="/index.pl?node_id=118799">3-D Stereogram, Self replicating source.</a>
<br /><a HREF="/index.pl?node_id=45213">camel code</a><INSERTHERE>
</td>
<tr>
</table>