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

I install all required modules to convert crystal report file to PDF... but getting an error message that 'Bareword "SCALAR" not allowed while "strict subs" in use at C:/Perl/site/lib/DateTime/Locale.pm line 41.' The Locale.pm code at line 41 is :
my $class = shift;
my %p = validate(
@_, {
id => { type => SCALAR },
en_language => { type => SCALAR },
en_script => { type => SCALAR, optional => 1 },
en_territory => { type => SCALAR, optional => 1 },
en_variant => { type => SCALAR, optional => 1 },
native_language => { type => SCALAR, optional => 1 },
native_script => { type => SCALAR, optional => 1 },
native_territory => { type => SCALAR, optional => 1 },
native_variant => { type => SCALAR, optional => 1 },
class => { type => SCALAR, optional => 1 },
replace => { type => SCALAR, default => 0 }, }
);

I did everything that I could to troubleshoot the proble but no out put.. Please take me out of this..

  • Comment on Bareword "SCALAR" not allowed while "strict subs" in use at C:/Perl/site/lib/DateTime/Locale.pm line 41.

Replies are listed 'Best First'.
Re: Bareword "SCALAR" not allowed while "strict subs" in use at C:/Perl/site/lib/DateTime/Locale.pm line 41.
by kennethk (Abbot) on Aug 17, 2010 at 19:28 UTC
    If you trace SCALAR back, you will note it at the top of the module in the line: use Params::Validate qw( validate validate_pos SCALAR ); This line imports SCALAR into your namespace. Do you have Params::Validate in your path? Have you or one of your colleagues hacked this file or the Params/Validate.pm file?
      All other module I downloaded from CPAN site are installed using following syntax.
      perl makefile.pl
      dmake
      dmake install

      but the Params-Validate-0.95 modile dont have makefile.pl but there is build.pl so I run this file. I have the Validate.pm file located at C:\Perl\site\lib\Params folder in my machine. Also you mention "Do you have Params::Validate in your path?".. does this mean I have to update environment variable with some value.. and with what value?


      Please help
        What happens when you run the following script?

        #!/usr/bin/perl use strict; use warnings; use Params::Validate qw( validate validate_pos SCALAR ); print SCALAR, "\n";

        And this one?

        #!/usr/bin/perl use strict; use warnings; use DateTime::Locale; print "1\n";
Re: Bareword "SCALAR" not allowed while "strict subs" in use at C:/Perl/site/lib/DateTime/Locale.pm line 41.
by toolic (Bishop) on Aug 17, 2010 at 19:41 UTC
      Given below is the code line from Locale.pm file
      ----------------------------------------------
      package DateTime::Locale;
      use strict;
      use warnings;
      use 5.006;
      # Loading this here isn't necessary, but it makes it easier to catch
      # syntax errors when testing.
      use DateTime::Locale::Base;
      use DateTime::Locale::Catalog;
      use Params::Validate qw( validate validate_pos SCALAR );
      ----------------------------------------------------
      And given below is the codeline from my application

      use strict;
      use Win32::OLE;
      #use Win32::OLE::Variant;
      use Win32::OLE::CrystalRuntime::Application;
      # Produce a OLE Variant "FALSE" to pass to the Export method...
      my $false = Variant(VT_BOOL,0);

        Given below is the code line from Locale.pm file

        That isn't the code asked for. Which version of DateTime::Locale do you have and what is your code?

Re: Bareword "SCALAR" not allowed while "strict subs" in use at C:/Perl/site/lib/DateTime/Locale.pm line 41.
by SuicideJunkie (Vicar) on Aug 17, 2010 at 19:26 UTC

    SCALAR is a bareword. "SCALAR" is a string.

    You want a string, and => only autoquotes the left hand side.


    Append: Ah, never mind; that would apply if it were your own code and you didn't have a constant defined.

      do mean I have to update Validate.PM file ?