1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/perl
use strict;
my $verz="c:/Test";
sub verarbeite {
my @files;
my $x;
chdir "${verz}/$_[0]";
@files = glob("*.csv");
open OUT, ">", "${verz}/Ergebnis/$_[1]";
foreach my $file (@files) {
print "Searching $file\n";
#
#
#
verarbeite("Import", "*.csv"); #
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
#!/usr/bin/perl use strict; use warnings; my $verz="c:/Test"; sub verarbeite { my ($name, $dir, $glob) = @_; my @files = glob("$dir/$glob"); my $outdir="$dir/Ergebnis"; my $outfile="$outdir/$name"; if( @files ) { unless(-d $outdir) { mkdir($outdir) or die("Error mkdir $outdir : $!"); } open( my $fh, '>', $outfile) or die("Error open $outfile : $!"); for my $file (@files) { print "Searching $file\n"; # ... } close($fh); } } verarbeite("Import", $verz, "*.csv");
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
#!/usr/bin/perl use warnings; use strict; use File::Copy; my $indir = "C:/Test/Import"; my @crit = (["TTS3", "02502185"], ["TTS3", "CONFIRM"], ["TTS3", "02502106"], ["TTS3", "02502100"]); my @dirs = ("GGR", "Confirm", "Nack", "Ack"); sub createDir { my $dirname =shift; if (! -e $dirname) { # mkdir($dirname); print "$dirname\n"; } } chdir($indir); my @files = glob("*.CSV"); my $dirname; for my $i (@files) { for my $u (0 .. $#crit) { if ($i =~ /\Q$crit[$u][0]\E/ && $i =~ /\Q$crit[$u][1]\E/) { if ($dirs[$u] eq "Ack" || $dirs[$u] eq "GGR") { my $d2 = "$indir/AckGGR"; createDir($d2); my $t2 = "$d2/$i"; # copy($i, $t2); print "$i -> $t2\n"; } $dirname = "$indir/$dirs[$u]"; print "\n"; createDir($dirname); my $target = "$dirname/$i"; # move($i, $target); print "$i -> $target\n"; } } if ($i =~ /.{5}\.TTS3/) { $dirname = "$indir/Nic"; print "\n"; createDir($dirname); my $target = "$dirname/$i"; # move($i, $target); print "$i -> $target\n"; } }