Thread Filehandle. Output-Datei generieren (17 answers)
Opened by incubus at 2015-02-23 16:39

Gast incubus
 2015-02-23 20:57
#179852 #179852
Ich bin ja doch blöd. Was ist mein Problem, außer ich dumm bin?
Code (perl): (dl )
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
#!/usr/bin/perl

use strict;
use warnings;

my @list = qw(a b c);
my %fh;
foreach my $f(@list){
        foreach my $s(@list){
                my $key = $f.$s;
                open($fh{$key}, ">", "fh_$key.txt") or die;
        }
}

while(<DATA>){
        chomp;
        my $sub = substr($_, 0,2);
        print  $sub "$sub\n";
}

__DATA__
aaK
acK
bcK
baK
bbK

Würdest du bitte mein Code korrigieren? Wenn ich
Quote
use strict;
auskommentiere, dann bekomme ich, was ich haben möchte.
Code (perl): (dl )
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
#!/usr/bin/perl

#use strict;
use warnings;

my @list = qw(a b c);
foreach my $f(@list){
        foreach my $s(@list){
                my $aaa = $f.$s;
                open($aaa, ">", "test_$aaa.txt") or die;
        }
}

while(<DATA>){
        chomp;
        my $sub = substr($_, 0,2);
        print $sub "$sub\n";
}

__DATA__
aaK
acK
bcK
baK
bbK

Last edited: 2015-02-23 21:19:11 +0100 (CET)

View full thread Filehandle. Output-Datei generieren