First off, are you using strict and warnings? It doesn't look like you are. strict will tell you if you've misspelled a variable name, by complaining that it wasn't declared.

The second thing is to clean up your formatting! This sounds stupid, but how can you expect to have a clean-running program if your workspace (ie, your code) isn't neat and clean. I can barely read your code because there's random whitespace and logic isn't indented consistently. Indented consistently, your subroutine would look something like:

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 $archiv +e\\$sec_homepage\\data\\$key"; $cmd[1] = "del /Q $workarea\\$sec_homepage\\data\\ +$k +ey"; $cmd[2] = "$cmd_path\\iwsubmit -w -u $vpath/$submi +t/ +data/$key \"Content Expired.\""; $cmd[3] = "$cmd_path\\iwsubmit -w -u $vpath_arc/$s +ubmit/ +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, archive 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\\present +ation\\home.tpl -iw_pt-dcr $t_path\\home\\home\\data\\$home_sort[0] - +ofile $outf +ile"; $cmd1[1] = "$cmd_path\\iwsubmit -w -u $outfile \"ASP Created.\ +""; for my $j (0 .. 2) { print "$cmd1[$j]\n"; $rs2 = `$cmd1[$j]`; print "$rs\n"; } # End for loop to run commands } # End if } #end sub

------
/me wants to be the brightest bulb in the chandelier!

Vote paco for President!


In reply to Re: Debugging "Use of Unitialized Value" message by dragonchild
in thread 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.