By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,245 Members | 1,271 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,245 IT Pros & Developers. It's quick & easy.

To display last year calendar

P: 1
In my webpage, when i click "Past or Future" button to display "previous year leave summary or future year leave summary" respectively. It gives the error
"Can't use an undefined value as a HASH reference at LeaveSum.pm line 65."


Expand|Select|Wrap|Line Numbers
  1. sub leave_init {
  2.    ($mDBh,$mShortname,$mYear) = @_;
  3.    my $pToday;
  4.    my $pSql;
  5.    my ($pPrevYear,$pNextYear);
  6.  
  7.    SWITCH: {
  8.       if ($mYear eq "L") {
  9.          $pToday = "today - 1 units year";
  10.          last SWITCH;
  11.       }
  12.       if ($mYear eq "T") {
  13.          $pToday = "today";
  14.          last SWITCH;
  15.       }
  16.       if ($mYear eq "N") {
  17.          $pToday = "today + 1 units year";
  18.          last SWITCH;
  19.       }
  20.    }
  21.  
  22. 64:   $pSql = "select $pToday date from site_table";
  23. 65:   $mToday = ($mDBh->selectrow_hashref($pSql))->{date};
  24.  
  25.    if ($mToday =~ /-/) {
  26.       # date is returned in yyyy-mm-dd format so put back to dd/mm/yyyy
  27.       $mToday =~ /(\d+).(\d+).(\d+)/;
  28.       $mToday = "$3/$2/$1";
  29.    }
  30.  
  31.    $mToday =~ /\d+.\d+.(\d+)/;
  32.    $mYearNo = $1;
  33.  
  34.    $pPrevYear = $mYearNo -1;
  35.    $pNextYear = $mYearNo +1;
  36.  
  37.  
  38.    if (int_date($mToday) > int_date("31/03/$mYearNo")) {
  39.       @mFinDates = ( 
  40.          "01/04/$mYearNo", "31/03/$pNextYear",
  41.          "01/04/$pPrevYear", "31/03/$mYearNo"
  42.       );
  43.    }
  44.    else {
  45.       @mFinDates = ( 
  46.          "01/04/$pPrevYear", "31/03/$mYearNo",
  47.          "01/04/".eval("$pPrevYear-1"), "31/03/$pPrevYear"
  48.       );
  49.    }
  50.  
  51.    $mStart_date = "01/01/$mYearNo";
  52.    $mEnd_date = "31/12/$mYearNo";
  53.  
  54.    $mPrevStart = "01/01/$pPrevYear";
  55.    $mPrevEnd = "31/12/$pPrevYear";
  56.  
Can any one help plzzz
Feb 29 '08 #1
Share this Question
Share on Google+
1 Reply


KevinADC
Expert 2.5K+
P: 4,059
65: $mToday = ($mDBh->selectrow_hashref($pSql))->{date};

$mDBh appears to not be defined when your perl program tries to use it in the above line as a reference. You need to try and figure out why it's not defined (has no value).
Feb 29 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.