1 2 3 4 5 6 7 8 9 10 11 12
my @data; my $col=0; my %fields; foreach(@{$sth->{NAME_lc}}){ $fields{$_}=$col++; } while(my $ref=$sth->fetchrow_arrayref){ push @data,[@ref]; } my $var1=$data[0]->[$fields{column1}]; #->klappt, gibt Wert zurück my $var2=min @data->[$fields{column1}]; #->gibt Referenz zurück
push @data,[@ref];
@data->[$fields{column1}]
my $var2 = min map{ ( $_->[$fields{column1}] ) }@data
1 2 3
my @tmp; push(@tmp,$_->[$fields{column1}]) for(@data); my $var2 = min @tmp;
1 2 3 4 5 6 7 8 9 10 11 12 13 14
my @data; my $col=0; my %fields; foreach( @{$sth->{NAME_lc}} ){ $fields{$_} = $col++; } while(my $ref=$sth->fetchrow_arrayref){ push( @data, $ref ); } my $var1 = $data[0]->[$fields{column1}]; my $var2 = min map{ ( $_->[$fields{column1}] ) }@data;
1 2 3 4 5 6 7 8 9
my @data; my @data; while( my $ref = $sth->fetchrow_hashref() ){ push( @data, $ref ); } my $var1 = $data[0]->{column1}; my $var2 = min map{ $_->{column1} } @data;
Guest Enana-> push @data,[@$ref] habe ich in der while Schleife übergeben weil $ref sich die ganze Zeit selbst überschreibt.
my $x=100; while(my $x=0){} print $x
my $x=100; while($x=0){} print $x
QuoteNote that the same array reference is returned for each fetch, so don't store the reference and then use it after a later fetch. Also, the elements
of the array are also reused for each row, so take care if you want to take a reference to an element. See also "bind_columns".