I'm sure I'm missing something obvious, but for some reason my script seems to just hang near the end (WinXP, Activestate 5.8), even when I use die to try to kill it (it doesn't go back to the command prompt).

The script did exit earlier in its development, so I don't think it's the modules (although I did notice some interesting warnings being generated from the Spreadsheet::BasicRead module). If anyone can see anything structurally or syntactically (or otherwise) doing wrong, let me know. . . thank you. . .
Essentially, the idea is to pull down a publicly available spreadsheet, read some values in it, sum them, compare the sum to a value in the database, and then send an email if the values differ (eventually I may just do the update, but I want to run it awhile first).
#!perl use LWP::Simple; use LWP::UserAgent; use Mail::Sender; use DBI; use Spreadsheet::BasicRead; ($user, $pwd, $email) = @ARGV; $date = time(); ($sec, $min, $hour, $day, $mon, $year) = localtime $date; $curryear = $year + 1900; $xmon = sprintf ("%02d", $mon+1); $day = sprintf ("%02d", $day); $year =~ /\d\d(\d\d)/; $truncyear = $1; $name = "C:/sp500-".$xmon.$day.$truncyear.".xls"; &GetSNPfile($name); $spread = new Spreadsheet::BasicRead($name) || die "Error: $!"; print "Opened Spread...\n"; while ($data = $spread->getNextRow()){ last if ($$data[0] eq "ACTUALS"); next if !($$data[0] =~ m,/\d+/,); $$data[0] =~ m,/\d{2}/(\d{4}),; $year = $1; push @ests, $$data[2]; } print join "\t", @ests; @fwd_four = (reverse @ests)[0..3]; for (@fwd_four){$sum+=$_;} print "\n".$sum."\n"; $dbh = DBI->connect('dbi:Oracle:host=oraclehost;sid=dbsid', $user, $pwd, { RaiseError => 1, PrintError => 1 } ); $getsnp = $dbh->prepare("Select COLUMN from TABLE where ANOTHERCOLUMN += ?"); $getsnp->execute($curryear + 1); @row = $getsnp->fetchrow_array; ($snp_eps)=@row; if($snp_eps != $sum){ $result = "Different values!\nDB:\t$snp_eps \nWEB:\t$sum"; } else{ $result = "Same values. . . \nDB:\t$snp_eps \nWEB:\t$sum"; } print $result; $sender = new Mail::Sender {smtp => 'mail.mailhost.com', from => 'scg@mailhost.com'}; $sender->MailMsg({to => $email, subject => "Message", msg => $result}); die "silly program doesn't know it's over"; sub GetSNPfile{ ($get) = @_; print "Getting SNP file from web. . . \n"; $snp = getstore("http://www2.standardandpoors.com/spf/xls/index/SP500E +PSEST.XLS", $get); print "Done getting file. . . \n"; $snp; }

In reply to Script no longer exiting by SamCG

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.