[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

6.6

Use of uninitialized value in subroutine entry  - perl script error - long

Asked by xscousr in Perl Programming Language

Tags: perl, uninitialized, value, subroutine

I have a script which compares the returned value of a script 45 seconds apart. Depending
on whether the two returned values are the same the script either exits or emails a notification.

I had to change the way the value is generated. Previously i was using sqsh but since we moved to sql 2000 i had to find another way. So, i am using DBI::Sybase.

The main script runs and as part of it runs the first script, the first script runs a query and gets a timestamp,
this populates the variable in the main.

---------------------------------------------------------------------------------------

#!/usr/bin/perl -w
BEGIN { $ENV{SYBASE} = '/usr/local/freetds'; }
#
# test the db2 dbi driver
use warnings;
use strict;
use DBI ;
my $dbh = DBI-> connect( 'dbi:Sybase:server=sql1','user','password',{ RaiseError => 1, AutoCommit => 0} ) || die "Database connection not made: $DBI::errstr\n";
 
 
   my $sql= "select TIMESTMP from UPLOAD where TIMESTMP = (select MAX (TIMESTMP) from UPLOAD)select UPLOADED from UPLOAD where UPLOADED <1;";
               
   my $sth = $dbh->prepare ($sql)|| die "Prepare failed: $DBI::errstr\n";
         
   $sth->execute() || die "Couldn't execute query:$DBI::errstr\n";
 
 
     while(my @array = $sth->fetchrow())
     {
       print "@array\n";
     }
     $sth->finish();
     $dbh->disconnect() || die "Failed to disconnect\n";
---------------------------------------------------------------------------------------

an example of the output provided by the query script (above) is

[bluemoon@box scripts]$ perl query.pl
2004060314:17:24/377

the idea is to get two values 45sec apart - these should always be the same. If they differ it means a process is down that we rely on.

BUT when i run the script i get back an error;

the error is;

Use of uninitialized value in subroutine entry at bluemoonchk.pl line 50.
Date::Calc::Delta_DHMS(): not a valid date at bluemoonchk.pl line 50.

Could be simple, could be hard - 500pts up for grabs.

thanks for any help.


here is the second script

---------------------------------------------------------------------------------------
#!/usr/bin/perl -w
 
use Date::Calc qw(Delta_DHMS);
use Date::Calc qw(Delta_Days);
 
use POSIX qw(strftime);
require Symbol;
 
$SENDMAIL_EXEC      = '/usr/sbin/sendmail';     # Path to sendmail(8)
$BLUEMOON_RECV_EMAIL = 'xscousr@domain.com';
my $bluemoon_sender = "bluemoon_monitor\@domain.com";
 
my @today = (strftime("%Y", localtime(time)),strftime("%m", localtime(time)), strftime("%d", localtime(time)),strftime("%H", localtime(time)),strftime("%M", localtime(time)),strftime("%S", localtime(time)));
my @timestamp;
 
my $day;
my $year;
my $month;
my $hour;
my $minutes;
my $seconds;
my $Dd;
my $Dh;
my $Dm;
my $Ds;
 
my $SQLOutput1;
my $SQLOutput2;
my $zero;
 
my $bluemoon_body;
 
$SQLOutput1=`perl /home/bluemoon/scripts/query.pl`;
        exit unless $SQLOutput1;
                sleep (45);
$SQLOutput2=`perl /home/bluemoon/scripts/query.pl`;
        exit unless $SQLOutput2;
 
if ($SQLOutput1 ne $SQLOutput2) {
                exit;
        } else {
 
 
if ($SQLOutput1 =~ /(.)(.)(........)(....)(..)(..)(..)(.)(..)(.)(..)(....)/) { $zero = $2; $year = $4; $month = $5; $day = $6; $hour = $7; $minutes = $9; $seconds = $11; }
 
@timestamp = ($year, $month, $day, $hour, $minutes, $seconds);
 

########### THIS IS LINE 50 FROM THE RETURNED ERROR ###################

($Dd,$Dh,$Dm,$Ds) = Delta_DHMS(@timestamp,@today);

##########################################################
 
if (($Dd > 0 || $Dh > 0 || $Dm > 5 ) && $zero == 0 ) {
 
        $bluemoon_body = join('',"Blue Moon Timestamp Check has failed!\n\nThe UPLOADED Field = ",$zero,"\nThere has not been an update in ", $Dd," days, ", $Dh," hours and ", $Dm," minutes.\n\nPlease restart the interface or investigate\n\nBluemoon TimeStamp: ",@timestamp,"\nCurrent Timestamp:  ",@today);
 
        my $SEND_MAIL   = Symbol->gensym;
        open($SEND_MAIL, "|-") ||
        exec($SENDMAIL_EXEC, '-i', '-t', "-f$bluemoon_sender");
print $SEND_MAIL <<"EOF";
Date: @today
From: $bluemoon_sender
To: $BLUEMOON_RECV_EMAIL
Subject: Blue Moon is Down!
$bluemoon_body
EOF
close($SEND_MAIL);
 
}
}
---------------------------------------------------------------------------------------
[+][-]06/03/04 02:55 PM, ID: 11227761Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06/03/04 04:20 PM, ID: 11228215Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06/04/04 07:59 AM, ID: 11233304Assisted Solution

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]06/04/04 08:40 AM, ID: 11233775Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06/04/04 10:01 AM, ID: 11234579Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06/04/04 10:09 AM, ID: 11234665Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06/04/04 10:18 AM, ID: 11234754Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06/04/04 10:26 AM, ID: 11234819Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06/04/04 10:46 AM, ID: 11234990Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06/04/04 10:51 AM, ID: 11235051Assisted Solution

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]06/04/04 11:33 AM, ID: 11235408Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06/04/04 11:48 AM, ID: 11235534Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zone: Perl Programming Language
Tags: perl, uninitialized, value, subroutine
Sign Up Now!
Solution Provided By: poastal
Participating Experts: 4
Solution Grade: A
 
[+][-]06/04/04 12:23 PM, ID: 11235853Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06/04/04 12:26 PM, ID: 11235881Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06/04/04 12:32 PM, ID: 11235940Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06/04/04 12:36 PM, ID: 11235988Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091021-EE-VQP-81