[sf-perl] Line number confusion

David Alban extasia at gmail.com
Fri Mar 25 11:04:28 PST 2005


Greetings,

Perl seems to be reporting an error for a line which is a comment. 
Perhaps someone can tell me why this is happening.  I'm confused.

Thanks,
David

P.S.  I'm not asking for help debugging the code.  No problem doing
that.  I just want to understand why perl is reporting an error at a
comment line.  Thanks.

$ uname -a ; perl -v
SunOS myhost 5.8 Generic_117350-18 sun4u sparc SUNW,Ultra-Enterprise

This is perl, v5.8.0 built for sun4-solaris

Copyright 1987-2002, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using `man perl' or `perldoc perl'.  If you have access to the
Internet, point your browser at http://www.perl.com/, the Perl Home Page.


Errors:

  Date::Calc::Date_to_Time(): date out of range at
/usr/local/bin/shadrpt.pl line 746.
  Date::Calc::Date_to_Time(): date out of range at
/usr/local/bin/shadrpt.pl line 746.
  Date::Calc::Date_to_Time(): date out of range at
/usr/local/bin/shadrpt.pl line 754.

Code:

   732       # return epoch time (seconds from 1-01-1970 GMT) represented by
   733       # $days, which is given as days since 1-01-1970.  the shadow
   734       # file lists dates in terms of days since 1-01-1970.
   735  sub time_from_days {
   736    my $func = ( caller 0 )[ 3 ];
   737    my $days = shift;
   738  
   739    not defined $days and logdie "$func(): \$days undefined\n";
   740  
   741    $days =~ /^\s*$/ and $days = 0;
   742  
   743         # Date::Calc::Add_Delta_Days is expecting "absolute days"
   744         # (i.e., days starting January 1, Year 1 A.D., but the
units stored
   745         # in the shadow file are days since epoch (i.e., days since
   746         # 1-01-1970), so we "convert" the input days from days since
   747         # epoch to absolute days.
   748    my $abs_day = $epoch_abs_day + $days;
   749  
   750         # Then we use Add_Delta_Days to determine a year, month, and day
   751         # corresponding to the date represented by the absolute days.
   752    my ( $year, $month, $day ) = Add_Delta_Days( 1, 1, 1, $abs_day - 1 );
   753  
   754    Date_to_Time( $year, $month, $day, 0, 0, 0 );
   755  } # time_from_days

Line 754 is the *only* place in the program from which
Date::Calc::Date_to_Time() is called.

Code seen from debugger's perspective:

    DB<1> l 735+20
  735==>  sub time_from_days {
  736:      my $func = ( caller 0 )[ 3 ];
  737:      my $days = shift;
  738 
  739:      not defined $days and logdie "$func(): \$days undefined\n";
  740 
  741:      $days =~ /^\s*$/ and $days = 0;
  742 
  743            # Date::Calc::Add_Delta_Days is expecting "absolute days"
  744            # (i.e., days starting January 1, Year 1 A.D., but
the units stored
  745            # in the shadow file are days since epoch (i.e., days since
  746            # 1-01-1970), so we "convert" the input days from days since
  747            # epoch to absolute days.
  748:      my $abs_day = $epoch_abs_day + $days;
  749 
  750            # Then we use Add_Delta_Days to determine a year,
month, and day
  751            # corresponding to the date represented by the absolute days.
  752:      my ( $year, $month, $day ) = Add_Delta_Days( 1, 1, 1,
$abs_day - 1 );
  753 
  754:      Date_to_Time( $year, $month, $day, 0, 0, 0 );
  755     } # time_from_days

-- 
Live in a world of your own, but always welcome visitors.


More information about the SanFrancisco-pm mailing list