O
Orion93
Hi!
I use File::Find and actually my script edit all files in a treefiles but
don't exclude the files with extension define in extension.def.
The line "elsif ($tabext{$ficext} != undef) {}" doesn't work, I am not able
to say it to compare if the extension of the file find is inclue in
extension.def to exclude it.
Thanks...
Sophie
Sorry for my english...
Script:
-------
#!/usr/bin/perl -w
use strict;
use warnings;
use diagnostics;
use File::Find;
sub listePages {
my $ext1="c:\\result.txt";
my $direct="c:\\";
open (Desc, "< extension.def");
my %tabext;
while (<Desc>){
$tabext{$_}='1';
}
find(\&accounts, $direct);
sub accounts {
$File::Find::name =~ /(\..*)$/;
my $ficext = $1;
#Pour eliminer les dossiers
if (-d $File::Find::name) {}
#Pour eliminer les fichiers ayant une extension étant dans la liste
elsif ($tabext{$ficext} != undef) {}
else {
open SORTIE,">> $ext1";
print "$File::Find::name \n";
print SORTIE "$File::Find::name \n";
close SORTIE;
}
close Desc;
}
}
File extension.def
---------------------
..zip
..doc
..rtf
..xls
..etc
I use File::Find and actually my script edit all files in a treefiles but
don't exclude the files with extension define in extension.def.
The line "elsif ($tabext{$ficext} != undef) {}" doesn't work, I am not able
to say it to compare if the extension of the file find is inclue in
extension.def to exclude it.
Thanks...
Sophie
Sorry for my english...
Script:
-------
#!/usr/bin/perl -w
use strict;
use warnings;
use diagnostics;
use File::Find;
sub listePages {
my $ext1="c:\\result.txt";
my $direct="c:\\";
open (Desc, "< extension.def");
my %tabext;
while (<Desc>){
$tabext{$_}='1';
}
find(\&accounts, $direct);
sub accounts {
$File::Find::name =~ /(\..*)$/;
my $ficext = $1;
#Pour eliminer les dossiers
if (-d $File::Find::name) {}
#Pour eliminer les fichiers ayant une extension étant dans la liste
elsif ($tabext{$ficext} != undef) {}
else {
open SORTIE,">> $ext1";
print "$File::Find::name \n";
print SORTIE "$File::Find::name \n";
close SORTIE;
}
close Desc;
}
}
File extension.def
---------------------
..zip
..doc
..rtf
..xls
..etc