in reply to Re^3: Excel and Perl
in thread Excel and Perl

use strict; use warnings; use Spreadsheet::ParseExcel; use Spreadsheet::Read; my $ss = ReadData ("4_19_10_Zrc01a-2.xls"); my $s = $ss->[1]; my %max; foreach my $r (1 .. $s->{maxrow}) { my ($A, $B) = ($s->{cell}[5][$r], $s->{cell}[8][$r]); $max{$A} //= $B; $max{$A} < $B and $max{$A} = $B; } print "$_\t$max{$_}\n" for sort { $a <=> $b } keys %max;
the above code was given as a solution by wsfp, it doesn';t seemt to run for me and is giving me a long list of errors.
Use of uninitialized value $A in hash element at D:\Programming\Perl\R +ead.plx li ne 14. Use of uninitialized value $A in hash element at D:\Programming\Perl\R +ead.plx li ne 15. Use of uninitialized value $B in numeric lt (<) at D:\Programming\Perl +\Read.plx line 15. Use of uninitialized value in numeric lt (<) at D:\Programming\Perl\Re +ad.plx lin e 15. Use of uninitialized value $A in hash element at D:\Programming\Perl\R +ead.plx li ne 14. Use of uninitialized value $A in hash element at D:\Programming\Perl\R +ead.plx li ne 15. Use of uninitialized value $B in numeric lt (<) at D:\Programming\Perl +\Read.plx line 15. Use of uninitialized value in numeric lt (<) at D:\Programming\Perl\Re +ad.plx lin e 15. Use of uninitialized value $A in hash element at D:\Programming\Perl\R +ead.plx li ne 14. Use of uninitialized value $A in hash element at D:\Programming\Perl\R +ead.plx li ne 15. Argument " Mapped_Aux_Number" isn't numeric in numeric lt (<) +at D:\Prog ramming\Perl\Read.plx line 15. Argument " Mapped_Aux_Number" isn't numeric in numeric lt (<) +at D:\Prog ramming\Perl\Read.plx line 15. Argument "Volt" isn't numeric in numeric lt (<) at D:\Programming\Perl +\Read.plx line 15. Argument "Volt" isn't numeric in numeric lt (<) at D:\Programming\Perl +\Read.plx line 15. Argument "Comments" isn't numeric in sort at D:\Programming\Perl\Read. +plx line 1 8. Argument "" isn't numeric in sort at D:\Programming\Perl\Read.plx line + 18. Argument "After Conference 3rd test for series.\r\nmass .0037" isn't n +umeric in sort at D:\Programming\Perl\Read.plx line 18. Comments Volt Mapped_Aux_Number After Conference 3rd test for series. mass .0037 0
The above is the result after I run the program. thank you.

Replies are listed 'Best First'.
Re^5: Excel and Perl
by Tux (Canon) on Jun 09, 2011 at 17:47 UTC
    foreach my $r (1 .. $s->{maxrow}) { my ($A, $B) = ($s->{cell}[5][$r] // 0, $s->{cell}[8][$r] // 0); $max{$A} //= $B; $max{$A} < $B and $max{$A} = $B; }

    will take away all those warnings. I bet you don't want columns "A" and "B" then, now do you? You still have to select the correct columns! Let's take columns "C" and "T" with the alternative approach. Then you start reading the documentation.

    foreach my $r (1 .. $s->{maxrow}) { my ($key, $value) = ($s->{"C$r"} // 0, $s->{"T$r"} // 0); $max{$key} //= $value; $max{$key} < $value and $max{$key} = $value; }

    Enjoy, Have FUN! H.Merijn