Thread letzte Spalte in jeder zeile ändern: die zahlen durch best. zahl teilen (57 answers)
Opened by sabrina at 2006-10-18 18:37

bloonix
 2006-10-19 14:07
#70953 #70953
User since
2005-12-17
1615 Artikel
HausmeisterIn
[Homepage]
user image
Code: (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
use strict;
use warnings;

=file ./BLUBBER.txt
Bernstätter Roswita BLUBB\be3fr   66 715  457 6.7.2006 15:34
Gehring Sabrina  BLUBB\ge3fr   32 016   85  5.7.2006  16:45 5.7.2006 16:45
Heizmann-Bayer Dorothea BLUBB\heb3fr   12 025  194 9.5.2006  7:41 9.5.2006  7:50
Zeile-mit-KB kleiner-100 BLUBB\heb3fr   12  194 9.5.2006  7:41 9.5.2006  7:50
=cut

open my $fh, '<', './BLUBBER.txt' or die $!;

while (defined (my $line = <$fh>)) {
  my @array = (split /[\t\s\\]+/, $line)[0..7];
  my $x = pop @array;    # Uhrzeit oder Datum
  if ($x =~ /\./) {      # wenn x ein Datum ist
     pop @array;         # dann brauchen wir diese Zahl nicht
     my $y = pop @array; # aber diese zum Kontatinieren
     $array[-1] .= $y;
  } else {               # dann ist x eine Uhrzeit und KB < 100
     pop @array;         # die Uhrzeit brauchen wir nicht
     pop @array;         # die Zahl brauchen wir nicht
  }
  $array[-1] = sprintf('%.3f', $array[-1] / 1024);
  print join(';', @array), "\n"; # hier kannst du nach ZIEL.txt schreiben...
}

close $fh;


Edit: Trennzeichen bei join von : nach ; geändert\n\n

<!--EDIT|opi|1161252560-->
What is a good module? That's hard to say.
What is good code? That's also hard to say.
One man's Thing of Beauty is another's man's Evil Hack.

View full thread letzte Spalte in jeder zeile ändern: die zahlen durch best. zahl teilen