Thread mehrdimensionale Arrays: Elemente hinzufügen (16 answers)
Opened by peggy at 2004-08-09 14:19

peggy
 2004-08-09 15:15
#85608 #85608
User since
2004-07-23
29 Artikel
BenutzerIn
[default_avatar]
Huhu!
Leider teilt er nicht zwischen den wörtern, ich erhalte das gleiche array wie in @zeilen:
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
open(FILE, "testdatei.txt") or die("oops: $!\n");
$/ = undef;
$data = <FILE>;
close FILE;

my @zeilen = split(/\n/,$data);
my @tabelle;
push @tabelle, [ split / /,$_] for @zeilen;

use Data::Dumper;
print Dumper \@tabelle;


Ausgabe:
$VAR1 = [
[
' apfel banane baum grün rot ast bielef regen obst pflanze'
],
[
'apfel 1.000 0.700 0.700 0.809 0.500 0.702 0.200 0.301 0.902 0.609 '
],
[],
[
'banane 0.700 1.000 0.500 0.200 0.100 0.300 0.101 0.203 0.902 0.609'
],
[],
[
'baum 0.700 0.500 1.000 0.803 0.100 0.900 0.500 0.702 0.803 0.904'
],
[],
[
'grün 0.809 0.200 0.803 1.000 0.800 0.600 0.300 0.703 0.605 0.803'
],
[],
[
'rot 0.500 0.100 0.100 0.800 1.000 0.300 0.209 0.309 0.609 0.308'
],
[],
[
'ast 0.702 0.300 0.900 0.600 0.300 1.000 0.304 0.309 0.700 0.809 '
],
[],
[
'bielef 0.200 0.101 0.500 0.300 0.209 0.304 1.000 0.900 0.600 0.300'
],
[],
[
'regen 0.301 0.203 0.702 0.703 0.309 0.309 0.900 1.000 0.800 0.800'
],
[],
[
'obst 0.902 0.902 0.803 0.605 0.609 0.700 0.600 0.800 1.000 0.900'
],
[],
[
'pflanze 0.609 0.609 0.904 0.803 0.308 0.809 0.300 0.800 0.900 1.000'
]
];
editiert: vertan hatte\n\n

<!--EDIT|peggy|1092050261-->

View full thread mehrdimensionale Arrays: Elemente hinzufügen