Thread hilfe um Array funktion??
(15 answers)
Opened by Gast at 2008-03-26 17:09 Code (perl): (dl
)
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 #!/usr/bin/perl use strict; use warnings; use Spreadsheet::ParseExcel; my $xls = 'acc.xls'; exit unless -e $xls; my $parser = Spreadsheet::ParseExcel::Workbook->Parse( $xls ); my $sheet = $parser->{Worksheet}->[0]; $sheet->{MaxRow} ||= $sheet->{MinRow}; my %hash; for my $row ( $sheet->{MinRow} .. $sheet->{MaxRow} ){ my $acc = $sheet->{Cells}->[$row]->[1]; if( $acc and $acc->Value ne 'ACCNumber' ){ my $cell = $sheet->{Cells}->[$row]->[0]; push @{ $hash{ $acc->Value } }, $cell->Value; } } for my $key ( sort keys %hash ){ my $sum = 0; $sum += $_ for @{ $hash{$key} }; my $avg = $sum / scalar( @{ $hash{$key} } ); print "Acc: $key -> $avg\n"; } Funktioniert mit der Datei, die hier zu finden ist. OTRS-Erweiterungen (http://feature-addons.de/)
Frankfurt Perlmongers (http://frankfurt.pm/) -- Unterlagen OTRS-Workshop 2012: http://otrs.perl-services.de/workshop.html Perl-Entwicklung: http://perl-services.de/ |