Thanks Ken and Anonymous your suggestions helped which I have implemented. I'm getting undef where I defined sub/variables. Errors location are numbered in code (line no.)

Updated code.

our %worksheet; #header foreach my $criterion (@criteria) { $reportPath = "$report_loc/$criterion.xls"; $reportHash{$criterion}{"all"}{"reportPath"} = $reportPath; local *REPORT_HANDLE; if (! open(REPORT_HANDLE, ">$reportPath")) { abort("Couldn't open $reportPath: $!"); } binmode REPORT_HANDLE; # Always do this regardless of whether the +platform requires it. $reportPath = Spreadsheet::WriteExcel->new(\*REPORT_HANDLE); $worksheet{$criterion} = $reportPath->add_worksheet($criterion); &outputHeader(*REPORT_HANDLE,$reportPath,"all",$criterion,$workshe +et{$criterion}); $reportHash{$criterion}{"all"}{"reportHandle"} = *REPORT_HANDLE; $reportHash{$criterion}{"all"}{"total"} = 0; foreach my $group (@groups) { $reportPath = "$report_loc_ts_groups/$group/$group" . "_" . "$crit +erion.xls"; $reportHash{$criterion}{$group}{"reportPath"} = $reportPath; local *REPORT_HANDLE; if (! open(REPORT_HANDLE, ">$reportPath")) { abort("Couldn't open $reportPath: $!"); } binmode REPORT_HANDLE; # Always do this regardless of whether the +platform requires it. my $reportPath = Spreadsheet::WriteExcel->new(\*REPORT_HANDLE +); $worksheet{$group} = $reportPath->add_worksheet($group); &outputHeader(*REPORT_HANDLE,$reportPath,$group,$criterion,$wo +rksheet{$group}); $reportHash{$group}{$criterion}{$worksheet{$criterion}}{"repor +tHandle"} = *REPORT_HANDLE; $reportHash{$group}{$criterion}{$worksheet{$criterion}}{"total +"} = 0; } } # Print totals and close files! foreach my $criterion (@criteria) { (line 229) wrapUp($reportHash{"all"}{$criterion}{$worksheet{$criterio +n}}{"reportHandle"},$reportHash{"all"}{$criterion}{$worksheet{$criter +ion}}{"total"}); foreach my $group (@groups) { wrapUp($reportHash{$group}{$criterion}{$worksheet{$group}}{"report +Handle"},$reportHash{$group}{$criterion}{$worksheet{$group}}{"total"} +); } # End of foreach my $group (@groups) { } # End of foreach my $criterion (@criteria) { exit; sub outputHeader { my $reportHandle = $_[0]; my $reportPath = $_[1]; my $group = $_[2]; my $criterion = $_[3]; my $worksheet = $_[4]; my ($x,$y)=(0,0); my $groupOut = ""; if ($groupOut ne "all") { $groupOut = "$group - "; } my $criterionOut = "Files expire within current month ($current_y-$cu +rrent_mth)"; if ($criterion eq $criteria[1]) { $criterionOut = "Deleted (expired) Files"; } elsif ($criterion eq $criteria[2]) { $criterionOut = "Files found with invalid expiry_date"; } #$worksheet->write($y++, $x, "$groupOut$criterionOut" +, $format{bold}); # write_string() $worksheet->write($y++, $x, "$groupOut$criterionOut" + ); # write_string() $worksheet->write($y++, $x, "Date Run: ".localtime()."" + ); # write_string() $worksheet->write($y++, $x, + ); # write_blank() $worksheet->write($y++, $x, "Criteria: today's date : $tod_date" + ); # write_string() $worksheet->write($y++, $x, " time interval : on or before +today's date" ); # write_string() if ($group ne "all") { $worksheet->write($y++, $x, " teamsite group : $group" + ); # write_string() } $worksheet->write($y++, $x, " workarea : \$area" + ); # write_string() $worksheet->write($y++, $x, " directories : " + ); # write_string() $worksheet->write($y++, $x, + ); # write_blank() $worksheet->write($y++, $x, + ); # write_blank() $worksheet->write($y++, $x, uc($groupOut.$criterionOut) + ); # write_string() $worksheet->write($y++, $x, + ); # write_blank() # Simple text $worksheet->write($y++, $x, "Files"); } # End of sub outputHeader { sub wrapUp { my $reportHandle = $_[0]; my $reportPath = $_[1]; my $group = $_[2]; my $criterion = $_[3]; my $worksheet = $_[4]; my $total = $_[5]; my ($x,$y) = (0,16); (line 314) $worksheet->write($y++, $x, "total"); close($reportHandle); } # End of sub wrapUp {

Log error I'm getting

Uncaught exception from user code:

Can't call method "write" on an undefined value at /home/bsmart/excel_workbooks.ipl line 314.

main::wrapUp('undef','undef') called at /home/bsmart/excel_workbooks.ipl line 229


In reply to Re^3: isn't numeric in substr error by begood321
in thread isn't numeric in substr error by begood321

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.