Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

CODE REVIEW: Use of uninitialised value in string eq at inventur.pl line 66 - Can't use an undefined value as a HASH reference at inventur.pl line 66.

by timunix (Initiate)
on Mar 20, 2020 at 00:36 UTC ( #11114497=perlquestion: print w/replies, xml ) Need Help??

timunix has asked for the wisdom of the Perl Monks concerning the following question:

Hells Bells! Line 66 is the for loop head and it throws me the error in the title. I got no warnings!<q>perl -w inventur.pl</q> remains silent. Excel opens, the sheet is selected, the sheet is unprotected and the last_row variable contains 282 as expected.

Can you see any syntax errors or violations? What is causing this error? Any help is highly appreciated.

my @typen = ("Befestigungsmaterial", "Ausbaumaterial", "Hls", "Install +ation", "Profilholz", "Spanplatten", "Dachstuhlholz", "Deckenbalken", + "Wandelementholz", "Giebelbau", "Wandfertigung", "Individual"); ### MAIN ### excellent(@typen);
sub excellent{ my $filename = cwd . "/" . "inventur.xls"; #dateiname my $excel = CreateObject OLE "Excel.Application"; #excel-objekt er +stellen $excel -> {Visible} = 1; #parameter festlegen $excel->{DisplayAlerts}=0; my $workbook = $excel -> Workbooks -> Open($filename); # Arbeitsma +ppe öffnen foreach my $tbl (@_) { # Sheet selektieren my $sheet = $workbook -> Worksheets("$tbl"); $sheet -> Select; # Unprotect Sheet $sheet->Unprotect(); # leere Zeilen löschen our $last_row = $sheet -> Range("D1000")->End(xlUp)->Row; # le +tzte Zeile ermitteln for(my $i=11;$i<=$last_row;$i++) { if( $sheet->Range("D" . $i)->{Value} eq "0") { $sheet->Cells($i, 4)->EntireRow->Delete; } # Leerzeichen in Spalte entfernen #$sheet->Range("Q" . $i)->{Value}->Replace(What => " ", Re +placement => ""); } # Speichern und Schließen $workbook->SaveAs({Filename => cwd . "/$tbl.csv", FileFormat => xlCSV}); } $workbook->Close(); $excel->Quit(); }
  • Comment on CODE REVIEW: Use of uninitialised value in string eq at inventur.pl line 66 - Can't use an undefined value as a HASH reference at inventur.pl line 66.
  • Select or Download Code

Replies are listed 'Best First'.
Re: CODE REVIEW: Use of uninitialised value in string eq at inventur.pl line 66 - Can't use an undefined value as a HASH reference at inventur.pl line 66.
by tybalt89 (Parson) on Mar 20, 2020 at 01:08 UTC
    if( $sheet->Range("D" . $i)->{Value} eq "0")

    my guess is here, $sheet->Range("D" . $i) is not what you think it is

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://11114497]
Approved by haukex
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2020-06-05 07:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you really want to know if there is extraterrestrial life?



    Results (35 votes). Check out past polls.

    Notices?