I am receiving the message "Use of Uninitialized Value" at certain points when running my script. I have check all the variables and they are all set to the correct values. The program is outputting the correct stuff, but I am trying to clean up the code. Any ideas on the easiest way to debug this code? Here is the function I wrote:
sub gen_asp { my(@cmd) = (); my(@cmd1) = (); my($rs) = (); my($rs2) = (); my($submit) = $sec_homepage; $i = 0; $submit =~ tr |\\|/|; my(@keys) = keys %temp_dcr_hash; foreach $key (@keys){ if ("$temp_dcr_hash{$key}{LaunchDate2}" eq $today) { $home{$key} = $temp_dcr_hash{$key}; } # End of if statement } # End of foreach loop if ("(keys %home)" ne "" ){ foreach $key (@keys){ if("$temp_dcr_hash{$key}{LaunchDate2}" lt $today) { if ($key ne ""){ $cmd[0] = "copy $workarea\\$sec_homepage\\data\\$k +ey $archive\\$sec_homepage\\data\\$key"; $cmd[1] = "del /Q $workarea\\$sec_homepage +\\data\\$key"; $cmd[2] = "$cmd_path\\iwsubmit -w -u $vpat +h/$submit/data/$key \"Content Expired.\""; $cmd[3] = "$cmd_path\\iwsubmit -w -u $vpath_ar +c/$submit/data/$key \"Submitted to Staging.\""; } # End if statement for ($j=0; $j<4; $j++) { print "$cmd[$j]\n"; $rs = `$cmd[$j]`; print "$rs\n"; } # End for loop to run commands } # End if statement to check if the dcr is expired, arc +hive any that are and delete them from the site } # End foreach loop @home_sort = sort {$home{$b}{$modtime} <=> $home{$a}{$modtime} +} (keys %home); $outfile = "$workarea\\Index.asp"; $cmd1[0] = "$cmd_path\\iwpt_compile.ipl -pt $t_path\\home\\hom +e\\presentation\\home.tpl -iw_pt-dcr $t_path\\home\\home\\data\\$home +_sort[0] -ofile $outfile"; $cmd1[1] = "$cmd_path\\iwsubmit -w -u $outfile \"ASP Created.\ +""; for ($j=0; $j<2; $j++) { print "$cmd1[$j]\n"; $rs2 = `$cmd1[$j]`; print "$rs\n"; } # End for loop to run commands } # End if } #end sub
The issue arises in the command calls at the end, after cmd1[0] is run the error appears (a few times actually) and then the program completes the commands in the loop. Thanks, Bill

In reply to Debugging "Use of Unitialized Value" message by wstarrs

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.