|< 1 2 3 >| | 26 Einträge, 3 Seiten |
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
use FileHandle;
use strict 'vars';
my @files;
my $fileCount = 0;
my $file;
my $tmp;
my $f;
# Create the files
for (my $i = 0; $i < 520; $i++ ) {
open(TOUCH, "touch cb$i.txt|") or die "could not touch the file $i";
close(TOUCH);
}
# open the dir handle
opendir(CURRENT, ".") or die "Could not open the current dir";
# open all files that start with "cb"
while ($file = readdir(CURRENT)) {
if($file =~ /^cb/) {
print "Open File Nr.: $fileCount $file\n";
### use the FileHandle
$tmp = new FileHandle($file, "w") or die "could not open $file";
push(@files, $tmp);
###
### Comment in to use the normal open function of perl
# open($file, ">$file") or die "error 1";
# push(@files, $file);
###
$fileCount++;
}
}
# Write one line in each file and close the file
foreach $f (@files) {
## Use the FileHandle
$f->print("Hi my name is $f");
$f->close() or die "error 2";
## Comment in to use the normal open function of perl
# print $f ("Hi my name is $f");
# close($f) or die "error 2";
}
|< 1 2 3 >| | 26 Einträge, 3 Seiten |