1 2 3 4 5 6 7 8 9 10
my $data = [ [], [3], [10,10], [10,10,3], [10,10,3,3], [10,10,3,2,3], [10,10,3,3,3,3], [10,10,7,10,7,8,10] ];
1 2 3 4 5 6 7 8 9 10 11 12
#!/usr/bin/perl use strict; use warnings; my @data_array; while(<>){ #chomp; @_=split(/,/,$_); push @data_array, \@_; } my $data = \@data_array;
print Dumper $data;
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
[
$VAR1 = [
''
],
[
'3'
],
[
'10',
'10'
],
[
'10',
'10',
'3'
],
[
'10',
'10',
'3',
'3'
],
[
'10',
'10',
'3',
'2',
'3'
],
[
'10',
'10',
'3',
'3',
'3',
'3'
],
[
'10',
'10',
'7',
'10',
'7',
'8',
'10'
]
];
'
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 29 30 31 32 33
#!/usr/bin/perl use strict; use warnings; use Algorithm::Cluster; my $data = [ [], [3], [10,10], [10,10,3], [10,10,3,3], [10,10,3,2,3], [10,10,3,3,3,3], [10,10,7,10,7,8,10] ]; print "-------[pairwise average linkage]-------\n"; my %params = ( method => 'a', data => $data ); my ($i,$j,$n); my $tree = Algorithm::Cluster::treecluster(%params); $n = $tree->length; for ($i = 0; $i < $n; $i++) { my $node = $tree->get($i); printf("%3d: %3d %3d %7.3f\n",-1-$i,$node->left,$node->right,$node->distance); }
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 29 30
#!/usr/bin/perl use strict; use warnings; use Algorithm::Cluster; use Data::Dumper; my @data_array; while(<>){ chomp; push @data_array, [split(/,/,$_)]; } my $data = \@data_array; print "-------[pairwise average linkage]-------\n"; my %params = ( method => 'a', data => $data ); my ($i,$j,$n); my $tree = Algorithm::Cluster::treecluster(%params); $n = $tree->length; for ($i = 0; $i < $n; $i++) { my $node = $tree->get($i); printf("%3d: %3d %3d %7.3f\n",-1-$i,$node->left,$node->right,$node->distance); }
1 2 3 4 5 6 7 8 9 10 11 12 13 14
#!/usr/bin/perl use strict; use warnings; my @data_array; while(<>){ chomp; push @data_array, [split(/,/,$_)]; } my $data = \@data_array; print "$data->[0][0]\n";
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
#!/usr/bin/perl use strict; use warnings; my @data_array; while(<DATA>){ chomp; push @data_array, [split(/,/,$_)]; } my $data = \@data_array; print "$data->[0][0]\n"; __DATA__ 3 10,10 10,10,3 10,10,3,3 10,10,3,2,3 10,10,3,3,3,3 10,10,7,10,7,8,10
1
2
3
4
5
6
7
8
9
# Test mit Linux Umbrüchen
$ echo -e "\n1\n2,2\n3,3,3" | perl kimmy1.pl
Use of uninitialized value in print at kimmy1.pl line 15, <> line 4.
$
# Test mit DOS Umbrüchen
$ echo -e "\r\n1\r\n2,2\r\n3,3,3" | perl kimmy1.pl
$
1
2
3
Test mit Mac :
machintosh:diverse kimmy$ echo -e "\n1\n2,2\n3,3,3" | perl AoA.pl
Use of uninitialized value in concatenation (.) or string at AoA.pl line 15, <> line 4.
2011-09-30T07:45:49 kimmyDu hast ja doch gesagt, dass es ein Bug von Perl ist. Ich habe einfach dir geglaubt.
2011-09-29T10:07:09 pqauch mit diesem aufruf bekomme ich eine warnung bei skript 1.
This is perl, v5.10.1 (*) built for i486-linux-gnu-thread-multi
um herauszufinden, was genau passiert, wird dir nichts anderes übrigbleiben, als die zeilen selber zu debuggen, um sicherzugehen, dass alle zeilen inklusive der leerzeile auch im skript ankommen.
wenn ja, und wenn trotzdem keine warnung kommt, ist es ein bug in perl.
1 2 3 4 5 6 7 8 9 10 11
#!/usr/bin/perl use strict; use warnings; use Data::Dumper; $Data::Dumper::Useqq = 1; my @lines = <>; # bzw. # my @lines = <DATA>; print Dumper \@lines;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
machintosh:Clustering kimmy$ perl debuggig.pl input.txt
$VAR1 = [
"\n",
"3\n",
"10,10\n",
"10,10,3\n",
"10,10,3,3\n",
"10,10,3,2,3\n",
"10,10,3,3,3,3\n",
"10,10,7,10,7,8,10\n"
];
machintosh:Clustering kimmy$ perl debuggig.pl
$VAR1 = [
"\n",
"3\n",
"10,10\n",
"10,10,3\n",
"10,10,3,3\n",
"10,10,3,2,3\n",
"10,10,3,3,3,3\n",
"10,10,7,10,7,8,10\n"
];
1 2 3 4 5 6 7 8 9 10 11 12 13
#!/usr/bin/perl use strict; use warnings; use Data::Dumper; $Data::Dumper::Useqq = 1; my @data_array; while(<DATA>){ # bzw. <> chomp; push @data_array, [split(/,/,$_)]; } print Dumper \@data_array;
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
machintosh:Clustering kimmy$ perl debuggig.pl
$VAR1 = [
[],
[
3
],
[
10,
10
],
[
10,
10,
3
],
[
10,
10,
3,
3
],
[
10,
10,
3,
2,
3
],
[
10,
10,
3,
3,
3,
3
],
[
10,
10,
7,
10,
7,
8,
10
]
];
machintosh:Clustering kimmy$ perl debuggig.pl input.txt
$VAR1 = [
[],
[
3
],
[
10,
10
],
[
10,
10,
3
],
[
10,
10,
3,
3
],
[
10,
10,
3,
2,
3
],
[
10,
10,
3,
3,
3,
3
],
[
10,
10,
7,
10,
7,
8,
10
]
];
1
2
3
4
5
6
7
8
9
10
11
12
13
14
$ xxd kimmy1.pl
0000000: 2321 2f75 7372 2f62 696e 2f70 6572 6c0a #!/usr/bin/perl.
0000010: 2320 7669 6d3a 2073 6574 2074 733d 3420 # vim: set ts=4
0000020: 7377 3d34 2065 7420 7374 613a 0a75 7365 sw=4 et sta:.use
0000030: 2073 7472 6963 743b 0a75 7365 2077 6172 strict;.use war
0000040: 6e69 6e67 733b 0a0a 6d79 2040 6172 7261 nings;..my @arra
0000050: 793b 0a0a 7768 696c 6520 2820 3c3e 2029 y;..while ( <> )
0000060: 207b 0a20 2020 2063 686f 6d70 3b0a 2020 {. chomp;.
0000070: 2020 7075 7368 2040 6172 7261 792c 205b push @array, [
0000080: 2073 706c 6974 202f 2c2f 2c20 245f 205d split /,/, $_ ]
0000090: 3b0a 7d0a 0a6d 7920 2464 6174 6120 3d20 ;.}..my $data =
00000a0: 5c40 6172 7261 793b 0a0a 7072 696e 7420 \@array;..print
00000b0: 2464 6174 612d 3e5b 305d 5b30 5d2c 2022 $data->[0][0], "
00000c0: 5c6e 223b 0a0a 0a \n";...