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

Hi.

I am porting a Perl application from a Windows 2005/IIS host to RHEL 6.5/Apache. In the course of the port we are also upgrading from ActiveState Perl 5.8 to Perl 5.10.

One of the tools that runs as part of the app uses the Perl DateTime library. This library is, dependent on the Params::Validate library by the same author. Both of these libraries are up to date:

[dcoleman@test1-cm3 perl]$ sudo cpanm DateTime DateTime is up to date. (1.18) [dcoleman@test1-cm3 perl]$ sudo cpanm Params::Validate Params::Validate is up to date. (1.18)

Our use of the DateTime library is pretty straight forward:

my $dtNow = DateTime->now;

But that's where the fun starts. Where the code running in ActiveState Perl 5.8 on Windows has run fine for years, since I ported the code I get the following when attempting to load that DateTime library:

Software error: Bareword "SCALAR" not allowed while "strict subs" in use at /var/www/l +ib/perl/DateTime/Duration.pm line 17. Bareword "SCALAR" not allowed while "strict subs" in use at /var/www/l +ib/perl/DateTime/Duration.pm line 17. Bareword "SCALAR" not allowed while "strict subs" in use at /var/www/l +ib/perl/DateTime/Duration.pm line 17. Bareword "SCALAR" not allowed while "strict subs" in use at /var/www/l +ib/perl/DateTime/Duration.pm line 17. Bareword "SCALAR" not allowed while "strict subs" in use at /var/www/l +ib/perl/DateTime/Duration.pm line 17. Bareword "SCALAR" not allowed while "strict subs" in use at /var/www/l +ib/perl/DateTime/Duration.pm line 17. Bareword "SCALAR" not allowed while "strict subs" in use at /var/www/l +ib/perl/DateTime/Duration.pm line 17. Bareword "SCALAR" not allowed while "strict subs" in use at /var/www/l +ib/perl/DateTime/Duration.pm line 17. Compilation failed in require at /var/www/lib/perl/DateTime.pm line 10 +. BEGIN failed--compilation aborted at /var/www/lib/perl/DateTime.pm lin +e 10. Compilation failed in require at /var/www/lib/perl/JobQJob.pm line 36. BEGIN failed--compilation aborted at /var/www/lib/perl/JobQJob.pm line + 36. Compilation failed in require at /var/www/admin/cgi-bin/pushlive.pl li +ne 27. BEGIN failed--compilation aborted at /var/www/admin/cgi-bin/pushlive.p +l line 27. For help, please send mail to the webmaster (root@localhost), giving t +his error message and the time and date of the error.

The DateTime::Duration module where the problem is showing up looks like:

package DateTime::Duration; use strict; use Params::Validate qw( validate SCALAR ); . . . sub new { my $class = shift; my %p = validate( @_, { years => { type => SCALAR, default => 0 } +, months => { type => SCALAR, default => 0 } +, weeks => { type => SCALAR, default => 0 } +, days => { type => SCALAR, default => 0 } +, hours => { type => SCALAR, default => 0 } +, minutes => { type => SCALAR, default => 0 } +, seconds => { type => SCALAR, default => 0 } +, end_of_month => { type => SCALAR, default = +> 'wrap' }, } ); . . .

The problem appears to be identical to the issue at http://www.perlmonks.org/?node_id=855574 but it looks like the discussion under that issue just got dropped before there was any resolution.

Has anyone encountered this before? Any ideas what the cause/resolution might be? What other information can I provide?

Thanks in advance.

Dennis

Replies are listed 'Best First'.
Re: DateTime::Duration - bareword SCALAR not allowed
by LanX (Saint) on Feb 21, 2015 at 14:43 UTC
Re: DateTime::Duration - bareword SCALAR not allowed
by dgcoleman (Initiate) on Feb 21, 2015 at 14:20 UTC

    Sorry about not linking to the CPAN site or the previous issue but attempting to do so gave me a permission error so I had to remove the links.

    D
Re: DateTime::Duration - bareword SCALAR not allowed
by Anonymous Monk on Feb 22, 2015 at 09:25 UTC

    ... sudo cpanm DateTime DateTime is up to date. (1.18) ...

    But what directory is it installed in?

      Thanks Anonymous Monk.

      Actually, your question led to the fix. It turns out that the DateTime and Params::Validate libraries were installed in two places. I suppose this might be a relic from back when this was originally built. I caught the DateTime double and renamed it but had missed the Params::Validate double. Once I moved that relic the code ran fine.

      This was just a matter of an updated DateTime depending on an obsolete Params::Validate library.

      Thanks for the clue.

      D.