-f patternfile werkt nu ook

wat debugging zooi weggehaald
This commit is contained in:
Ward Wouts 2001-08-01 09:03:18 +00:00
parent 7087a82261
commit c9e5806028

View file

@ -26,6 +26,8 @@ closedir(DIRHANDLE);
&lock; &lock;
if ($opt_f) { &read_pattern; }
if (@pattern) { if (@pattern) {
@target = @source; @target = @source;
&pattern_edit; &pattern_edit;
@ -57,6 +59,7 @@ if (@unsafe = &check_safety(\@source, \@target)) {
# final move # final move
&move_files(\@source, \@target); &move_files(\@source, \@target);
if ( -e ".mv_wrap" ) { unlink (".mv_wrap"); }
######################################################## ########################################################
@ -107,9 +110,14 @@ sub move_files {
} }
} }
sub read_pattern {
open PAT, "< $opt_f" or die "Couldn't open pattern file: $?\n";
@pattern = <PAT>;
close PAT;
}
sub pattern_edit { sub pattern_edit {
my (@new_target, $pat); my (@new_target, $pat);
foreach (@target) {print ;}
foreach $pat (@pattern) { foreach $pat (@pattern) {
@new_target=(); @new_target=();
foreach(@target) { foreach(@target) {
@ -117,11 +125,9 @@ sub pattern_edit {
push @new_target, $_; push @new_target, $_;
} }
@target = @new_target; @target = @new_target;
foreach (@target) {print;}
} }
} }
# returns 0 if all entries in @target_list are unique. 1 if not. # returns 0 if all entries in @target_list are unique. 1 if not.
sub check_unique (@target_list){ sub check_unique (@target_list){
my @uniqu; my @uniqu;
@ -192,13 +198,14 @@ sub unlock {
sub cmdline { sub cmdline {
%optctl = (); %optctl = ();
# getopts("e:hp:", \%option); # getopts("e:hp:", \%option);
&GetOptions("e=s", "h", "p=s", \@pattern); &GetOptions("e=s", "h", "p=s", \@pattern, "f=s");
&GetOptions(\%optctl, "e"); &GetOptions(\%optctl, "e");
&help if $opt_h; &help if $opt_h;
} }
sub help { sub help {
$opt_h = 1; # just get rid of that stupid message from -w
print << "EOT"; print << "EOT";
This is a little script to make renaming large quantities of files easy. This is a little script to make renaming large quantities of files easy.
@ -208,8 +215,8 @@ environment variable. Which in turn can be overridden with the -e option.
At the moment it takes the following options: At the moment it takes the following options:
-h this help message -h this help message
-e "editor" invoke with this editor -e "editor" invoke with this editor; ignored if -f or -p is given
-p "pattern" use a pattern to edit -p "pattern" use a pattern to edit; ignored if -f is given
-f "file" use a pattern file to edit -f "file" use a pattern file to edit
EOT EOT