Hello!
I'm trying to use File::Basename, but it is not behaving well:
tessio@pacman:~/tmp/ASAP$ ls
book.div book.tex erotic.div erotic.tex erotyc.tex problem source.a
source.c source.o
tessio@pacman:~/tmp/ASAP$ cat problem
use 5.010;
use strict;
use warnings;
use File::Basename;
my %sufixTable = (
'.div' => '.tex',
'.o' => '.c',
'.a' => '.c',
);
opendir my $DIR, '.' or die "Unable to open dir: $!\n";
my @list = readdir $DIR or die "Unable to read dir: $!\n";
foreach my $item ( @list ) {
next if $item eq '.';
next if $item eq '..';
# BUG! fileparse is doing it wrong!
my ( $file, $dir, $sufix ) = fileparse( $item, %sufixTable );
print "$file -> $sufix\n";
}
tessio@pacman:~/tmp/ASAP$ perl problem
erot -> ic.tex
(ERRO)
book -> .div
erot -> yc.tex
(ERRO)
problem ->
book -> .tex
source -> .c
source -> .a
source -> .o
erot -> ic.div
(ERRO)
tessio@pacman:~/tmp/ASAP$
---
Note that it is not working with erotic and erotyc file names.. Why?
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/