-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;
if ($opt_f) { &read_pattern; }
if (@pattern) {
@target = @source;
&pattern_edit;
@ -57,6 +59,7 @@ if (@unsafe = &check_safety(\@source, \@target)) {
# final move
&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 {
my (@new_target, $pat);
foreach (@target) {print ;}
foreach $pat (@pattern) {
@new_target=();
foreach(@target) {
@ -117,11 +125,9 @@ sub pattern_edit {
push @new_target, $_;
}
@target = @new_target;
foreach (@target) {print;}
}
}
# returns 0 if all entries in @target_list are unique. 1 if not.
sub check_unique (@target_list){
my @uniqu;
@ -192,13 +198,14 @@ sub unlock {
sub cmdline {
%optctl = ();
# getopts("e:hp:", \%option);
&GetOptions("e=s", "h", "p=s", \@pattern);
&GetOptions("e=s", "h", "p=s", \@pattern, "f=s");
&GetOptions(\%optctl, "e");
&help if $opt_h;
}
sub help {
$opt_h = 1; # just get rid of that stupid message from -w
print << "EOT";
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:
-h this help message
-e "editor" invoke with this editor
-p "pattern" use a pattern to edit
-e "editor" invoke with this editor; ignored if -f or -p is given
-p "pattern" use a pattern to edit; ignored if -f is given
-f "file" use a pattern file to edit
EOT