Leser: 35
![]() |
|< 1 2 3 >| | ![]() |
22 Einträge, 3 Seiten |
push(@file_3_[$i],$array_file3[$i]);
QuoteType of arg 1 to push must be array (not array slice) at /na/home/jungd/bin/Glaskugel line 91, near "])"
push @{ $file_3[$i] }, $array_file3[$i];
push @{ $file_3[$i] }, $array_file3[$i];
1 2 3 4 5 6 7
# wert Auslesen my $value_von_array_file_3_i=$array_file_3[$i]; # Referenz auf ein Array auslesen my $value_von_file_3_i=$file_3[$i]; # Das Array derefenezieren ( das macht das "@{}") und # das Element dem Array hinzufügen push( @{$value_von_file_3_i}, $value_von_array_file_3_i );
Guest DanielDanke schön!
Kannst du mir evtl irgendwie erklären was genau dabei abläuft?
@file_3_[$i]
@{file_3_} [$i]
2009-04-29T16:11:53 LanX-
Quotewas aber ein Hashslice ist!
1 2 3 4 5
while (<FILETOREAD>) { # read each line of file, one at a time $xyz = $_; push(@values1,[split(/\,/,$xyz)]); } close (FILETOREAD);
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
@files_to_read = @ARGV; $arrayzaehler = 1; foreach (@files_to_read){ $filename = $_; #Einlesen und Speichern der Datenfiles open (FILETOREAD, "<$filename") || die "Can't open $filename: $!"; while (<FILETOREAD>) { # read each line of file, one at a time $i++; chomp; if (/^\#/){ next } #Kommentarzeilen im .csv-file überspringen s/\s*//g; $xyz = $_; @zeile = split(/\,/,$xyz); push @{ @values[$arrayzaehler] }, [split(/\,/,$xyz)]; $arrayzaehler = ++$arrayzaehler;
push @{ $values{$filename} }, [split(/\,/,$xyz)];
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
#!/usr/bin/perl use strict; use warnings; my @files_to_read = @ARGV; # vorher initalisieren ist besser my @values; foreach my $filename (@files_to_read) { #Einlesen und Speichern der Datenfiles open (FILETOREAD, '<', $filename) || die "Can't open $filename: $!"; # read each line of file, one at a time while (my $line = <FILETOREAD>) { chomp($line); if ($line=~/^\#/){ next } #Kommentarzeilen im .csv-file überspringen $line=~s/\s+//g; # das reicht völlig aus # so hängst du an das Array @values # eine Arrayrefenzen mit den den gesplitteten Werten an # das ist ein Array of Arrays push(@values, [split(/\,/,$line)]); } close(FILETOREAD); } # mal alles ausgeben print join(', ', @$_)."\n" for(@values);
![]() |
|< 1 2 3 >| | ![]() |
22 Einträge, 3 Seiten |