perlquestion
McA
<p>Hi Monks,</p>
<p>just stumbled on the following behaviour of <code>File::Basename::basename</code>.
<code>
#!/usr/bin/perl
use 5.010;
use strict;
use warnings;
use File::Basename;
say "$File::Basename::VERSION\n";
my $filename = '';
say $filename, ' - basename($filename) -> ', basename($filename);
say $filename, ' - dirname($filename) -> ', dirname($filename);
</code>
The basename of an empty string is <code>./</code> which I really didn't expect. To cite the documentation:
<blockquote>
<i>dirname() and basename() emulate the behaviours, and quirks, of the shell and C functions of the same name. See each function's documentation for details.</i>
</blockquote>
But <code>basename</code> of empty string on bash is an empty string. The same for C library basename.</p>
<p>Is this a bug?</p>
<p>McA</p>