gri6507 has asked for the wisdom of the Perl Monks concerning the following question:

I have a simple test program (see below). When I run it directly through perl, I get the expected output. However, if I first PAR up the program and try to run the resulting executable, I get the following error message.
Name "Date::Manip::Lang::english::Language" used only once: possible typo at Date/Manip/Base.pm line 1844. Not an ARRAY reference at Date/Manip/Date.pm line 1351.

I do not understand what it means or how to work around it. Does anyone have any suggestions?

use strict; use warnings; use Date::Manip; my @dateObject; push @dateObject, ParseDateString('1/12/2010 10:44:49 AM'); push @dateObject, ParseDateString('1/12/2010 10:44:59 AM'); print "Delta is " . interval_to_sec(DateCalc(@dateObject)) . " seconds +\n"; # parse interval string and yield seconds sub interval_to_sec { my ($intv) = @_; my ($sec) = 0; my $sign = ($intv =~ /^-/) ? -1 : 1; my @f = reverse(split(/:/, $intv)); # use just 5 least significant fields $sec = $f[0]; $sec += $f[1] * 60; $sec += $f[2] * 3600; $sec += $f[3] * 86400; $sec += $f[4] * 604800; # 7 days $sec += $f[5] * 2629800; # 30.4 days (365.25 / 12) $sec += $f[6] * 31557600; # 365.25 days (Julian year) return $sign * $sec; }

Replies are listed 'Best First'.
Re: PAR::packer with Date::Manip gives error
by almut (Canon) on Jan 12, 2010 at 21:11 UTC

    My guesss would be that PAR did not include the Date/Manip/Lang/*.pm modules (they are being required dynamically at run-time, so dependency scanning appears to not have detected them).  Try including them explicitly using pp's -M option. (There are various modules for the individual languages; maybe it suffices in your case to just include .../english.pm)

      Thanks for the reply.

      I actually came to the same conclusion as you and explicitly added use Date::Manip::Lang::english; into my test program. This way, the PAR'ed up executable no longer reported the obscure message. Instead, it reports:

      Use of uninitialized value $beg in string comparison (cmp) at Date/Man +ip/TZ.pm line 1035. Use of uninitialized value $end in string comparison (cmp) at Date/Man +ip/TZ.pm line 1037. Use of uninitialized value $beg in string comparison (cmp) at Date/Man +ip/TZ.pm line 1035. Use of uninitialized value $end in string comparison (cmp) at Date/Man +ip/TZ.pm line 1037. Use of uninitialized value $y in length at Date/Manip/Base.pm line 222 +3. Use of uninitialized value $y in concatenation (.) or string at Date/M +anip/Base.pm line 2224. Use of uninitialized value $m in length at Date/Manip/Base.pm line 222 +6. Use of uninitialized value $d in length at Date/Manip/Base.pm line 222 +7. Use of uninitialized value $h in length at Date/Manip/Base.pm line 222 +8. Use of uninitialized value $mn in length at Date/Manip/Base.pm line 22 +29. Use of uninitialized value $s in length at Date/Manip/Base.pm line 223 +0. Use of uninitialized value $m in concatenation (.) or string at Date/M +anip/Base.pm line 2231. Use of uninitialized value $d in concatenation (.) or string at Date/M +anip/Base.pm line 2231. Use of uninitialized value $h in concatenation (.) or string at Date/M +anip/Base.pm line 2231. Use of uninitialized value $mn in concatenation (.) or string at Date/ +Manip/Base.pm line 2231. Use of uninitialized value $s in concatenation (.) or string at Date/M +anip/Base.pm line 2231. Use of uninitialized value $beg in string comparison (cmp) at Date/Man +ip/TZ.pm line 1035. Use of uninitialized value $end in string comparison (cmp) at Date/Man +ip/TZ.pm line 1037. Use of uninitialized value $year in addition (+) at Date/Manip/TZ.pm l +ine 1038. Use of uninitialized value $beg in string comparison (cmp) at Date/Man +ip/TZ.pm line 1035. Use of uninitialized value $end in string comparison (cmp) at Date/Man +ip/TZ.pm line 1037. Use of uninitialized value $y in length at Date/Manip/Base.pm line 222 +3. Use of uninitialized value $y in concatenation (.) or string at Date/M +anip/Base.pm line 2224. Use of uninitialized value $m in length at Date/Manip/Base.pm line 222 +6. Use of uninitialized value $d in length at Date/Manip/Base.pm line 222 +7. Use of uninitialized value $h in length at Date/Manip/Base.pm line 222 +8. Use of uninitialized value $mn in length at Date/Manip/Base.pm line 22 +29. Use of uninitialized value $s in length at Date/Manip/Base.pm line 223 +0. Use of uninitialized value $m in concatenation (.) or string at Date/M +anip/Base.pm line 2231. Use of uninitialized value $d in concatenation (.) or string at Date/M +anip/Base.pm line 2231. Use of uninitialized value $h in concatenation (.) or string at Date/M +anip/Base.pm line 2231. Use of uninitialized value $mn in concatenation (.) or string at Date/ +Manip/Base.pm line 2231. Use of uninitialized value $s in concatenation (.) or string at Date/M +anip/Base.pm line 2231. Use of uninitialized value $beg in string comparison (cmp) at Date/Man +ip/TZ.pm line 1035. Use of uninitialized value $end in string comparison (cmp) at Date/Man +ip/TZ.pm line 1037. Use of uninitialized value $year in addition (+) at Date/Manip/TZ.pm l +ine 1038. Use of uninitialized value $f[1] in multiplication (*) at script/try.p +l line 20. Use of uninitialized value $f[2] in multiplication (*) at script/try.p +l line 21. Use of uninitialized value $f[3] in multiplication (*) at script/try.p +l line 22. Use of uninitialized value $f[4] in multiplication (*) at script/try.p +l line 23. Use of uninitialized value $f[5] in multiplication (*) at script/try.p +l line 24. Use of uninitialized value $f[6] in multiplication (*) at script/try.p +l line 25. Delta is 0 seconds
      I have tracked it down to the Date::Manip::Date::date->parse method which is for some reason failing. Do you have any other suggestions?

        It's a little tedious to track down why those variables are uninitialized, but I'd think it's because still other modules are missing from the PAR package....  The author seems to have gone from one extreme to the other: in earlier releases, there was only one big Date/Manip.pm file, while the current release comes with around 940 individual .pm files :)  Not all of them are being loaded in every case...

        When I run your script under strace (my way of dependency scanning), it reveals the following modules effectively being used:

        $ strace -eopen ./817045.pl 2>&1 | grep 'Date/Manip.*= [0-9]\+$' open("./Date/Manip/Lang/english.pm", O_RDONLY) = 6 open("./Date/Manip.pm", O_RDONLY) = 8 open("./Date/Manip/Date.pm", O_RDONLY) = 9 open("./Date/Manip/Obj.pm", O_RDONLY) = 10 open("./Date/Manip/Base.pm", O_RDONLY) = 11 open("./Date/Manip/Lang/index.pm", O_RDONLY) = 11 open("./Date/Manip/TZ.pm", O_RDONLY) = 11 open("./Date/Manip/Zones.pm", O_RDONLY) = 11 open("./Date/Manip/Delta.pm", O_RDONLY) = 8 open("./Date/Manip/Recur.pm", O_RDONLY) = 8 open("./Date/Manip/TZ/euberl00.pm", O_RDONLY) = 4 open("./Date/Manip/TZ/etgmt00.pm", O_RDONLY) = 4

        You probably need to make sure those are part of the PAR package.  The TZ/* ones may be different in your case, so you might want to run the above strace command yourself... (in case you're on Linux/Unix)

        What version of perl and Date::Manip are you using?
Re: PAR::packer with Date::Manip gives error
by Anonymous Monk on Jan 12, 2010 at 22:37 UTC
    Use
    pp -x file.pl
    or better yet
    pp -a path/to/lib/Date/Manip;lib/Date/Manip file.pl