Thread Werte an der 6-ten Tab-stelle auslesen (17 answers)
Opened by Gast at 2006-10-16 02:04

bloonix
 2006-10-16 10:20
#70785 #70785
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
use strict;
use warnings;

my @treffer;
my $suche  = 1;
my $spalte = 5;
my @zeilen = (
  "120\t0\t1\t1\t0\t1\t0.5\t12",
  "130\t1\t0\t0\t0\t0\t0.4\t8",
  "130\t1\t0\t0\t0\tD\t0.4\t8",
);

while (defined (my $line = shift @zeilen)) {
  my $wert = (split/\t/, $line)[$spalte];
  push @treffer, $wert
     if $wert =~ /^$suche$/;
  # hier verwende ich mit Absicht nicht $wert == $suche,
  # denn falls $wert keine Zahl ist, wuerde '==' einen
  # Fehler ausloesen
}
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 Werte an der 6-ten Tab-stelle auslesen