Hallo,
ich hab als Bsp. zwei Dateien, der Inhalt ist eigentlich unwichtig.:
Datei_1:
svcd
Datei2:
szd
Ich oeffne alle (die Namen stehen in einem Array) und schreibe den Inhalt auf Console.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/usr/local/bin/perl -w
use strict;
our @bundle = ("Datei_1", "Datei2");
for(@bundle){
print "at begining: @bundle\n";
read_my_file($_);
}
sub read_my_file{
open(MODULES, $_) or die "Can't open $_: $!\n";
print "in subroutine: @bundle","\n"x2;
#while(defined(my $line = <MODULES>)){print $line," @bundle\n"; } # geht
while(<MODULES>){print "In file: $_","My files: @bundle\n"; }
close(MODULES);
print "at end of sr: @bundle\n";
}
print "@bundle\n$#bundle\n";
Ausgabe:
at begining: Datei_1 Datei2
in subroutine: Datei_1 Datei2
In file: svcd
My files: svcd
Datei2
at end of sr: Datei2
at begining: Datei2
in subroutine: Datei2
In file: szd
My files: szd
at end of sr:
1
Warum wird mein Array dabei geleert?
Wie kommt die Ausgabe "My files" zustande?\n\n
<!--EDIT|Jaque|1183707028-->