Thread Zeichenlimit einrichten (40 answers)
Opened by andy at 2013-05-03 14:53

Gast wer
 2013-05-31 13:01
#167891 #167891
Was sollen die Zuweisungen außerhalb der Schleife? Warum erst in ein Array lesen und dann bearbeiten? Warum globale Filehandles? Warum kein strict und warnings?

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
28
#!/usr/bin/perl
use strict;
use warnings;

my $in_file1='content.csv';
my $in_file2 'common.csv';
my $out_file='neu.csv';

my %gesetze;
open(my $ifh1, '<', $in_file1) or die "ERROR OPEN $in_file1 ($!)\n";
while(my $line=<$ifh1>) {
  chomp $line ;
  my ($nummer, $kuerzel, $gesetz) = split /;/, $line, 3;
  $gesetze{$kuerzel}=$gesetz;
}
close $ifh1;

open(my $ifh2, '<', $in_file2) or die "ERROR OPEN $in_file2 ($!)\n";
open(my $ofh,  '>', $out_file) or die "ERROR OPEN $out_file ($!)\n";
while(my $line=<$ifh1>) {
  chomp $line;
  my ($nummer, $kuerzel, $gesetz) = split /;/, $line, 3;
  if( exists $gesetze{$kuerzel} ) {
    print $ofh join(';', $kuerzel, $gesetze{$kuerzel}, $gesetz)."\n";
  }
}
close $ofh;
close $ifh2;

Last edited: 2013-05-31 13:18:46 +0200 (CEST)

View full thread Zeichenlimit einrichten