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

Gast incubus
 2015-02-23 21:27
#179853 #179853
Ich habe das Problem selber gelöscht, aber leider habe ich immer noch nicht ganz verstanden.
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
27
#!/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);
        my $filehandle =$fh{$sub};
        print  $filehandle "$sub\n";
}

__DATA__
aaK
acK
bcK
baK
bbK

Last edited: 2015-02-23 21:44:34 +0100 (CET)

View full thread Filehandle. Output-Datei generieren