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

our server group had recently upgraded the OS from AIX 5.2.9 to AIX 5.3 version. as far as i know the perl compilers was also upgraded from 5.8.0 to 5.8.2 version as it comes with the OS. when we run the our perl programs it appears that all of them is not working anymore. we are getting this error code:
Bareword "DBI::SQL_DATE" not allowed while "strict subs" in use at + /usr/opt/perl5/lib/5.8.2/aix-thread-multi/Time/Format.pm line 265. Bareword "DBI::SQL_INTEGER" not allowed while "strict subs" in use + at /usr/opt/perl5/lib/5.8.2/aix-thread-multi/Time/Format.pm line 265 +. Bareword "DBI::SQL_NUMERIC" not allowed while "strict subs" in use + at /usr/opt/perl5/lib/5.8.2/aix-thread-multi/Time/Format.pm line 265 +. Compilation failed in require at NYSDOT/Config/IniFiles.pm line 6. BEGIN failed--compilation aborted at NYSDOT/Config/IniFiles.pm lin +e 6. Compilation failed in require at stored_procedure.pl line 7. BEGIN failed--compilation aborted at stored_procedure.pl line 7.
i am novice to this perl and would appreciate if someone could tell what might be the issue? and how i might solve it. thanks, warren

Replies are listed 'Best First'.
Re: OS upgrade affecting perl causes all codes to abend
by almut (Canon) on Feb 26, 2008 at 21:39 UTC

    Hm, I don't think the error is related to a difference in strictness between versions 5.8.0 and 5.8.2.  I just verified that with 5.8.0, the following snippet would have produced the same "bareword not allowed" error that later versions do produce:

    use strict; my $v = DBI::SQL_DATE; # --> Bareword "DBI::SQL_DATE" not allowed wh +ile "strict subs" in use

    while this is fine:

    use strict; use DBI; my $v = DBI::SQL_DATE;

    (because DBI::SQL_DATE is a constant defined in the DBI module)

    In other words, I think your problem lies elsewhere. What's a bit weird is that the error is reported to be occurring in Time::Format ... a module dealing with an entirely different (not DBI related) problem domain. I looked at line 265 in the current version of the module: it's an eval { ... } setting up locale info via the module I18N::Langinfo — its possible relatedness to DBI stuff is escaping me at the moment :)

    Could you post line 265 (plus some context above and below) of your /usr/opt/perl5/lib/5.8.2/aix-thread-multi/Time/Format.pm file, as well as line 6 (plus context) of NYSDOT/Config/IniFiles.pm?

Re: OS upgrade affecting perl causes all codes to abend
by hipowls (Curate) on Feb 26, 2008 at 22:06 UTC

    Not much information to go on. I'd start by looking at the require Time::Format; in the BEGIN block in NYSDOT/Config/IniFiles.pm

    I'd also question why it was done that way when use Time::Format; outside a BEGIN block will almost certainly do what you want.

      thanks almut and hipowls. here is the codes. the Format.pm is too long and i have only posted the part that was related to the line 265. while the IniFiles.pm is the complete code. /usr/opt/perl5/lib/5.8.2/aix-thread-multi/Time/Format.pm
      package DBI::Format::String; @DBI::Format::String::ISA = qw(DBI::Format::Base); sub header { my($self, $sth, $fh, $sep) = @_; $self->{'fh'} = $self->setup_fh($fh); $self->{'sth'} = $sth; $self->{'data'} = []; $self->{sep} = $sep if defined $sep; my $types = $sth->{'TYPE'}; my @right_justify; my @widths; my $names = $sth->{'NAME'}; my $type; for (my $i = 0; $i < $sth->{'NUM_OF_FIELDS'}; $i++) { $type = $types->[$i]; push(@widths, ($type == DBI::SQL_DATE)? 8 : ($type == DBI::SQL_INTEGER and $sth->{PRECISION}->[$i] > 1 +5 )? 10 : ($type == DBI::SQL_NUMERIC and $sth->{PRECISION}->[$i] > 15 + )? 10 : defined($sth->{PRECISION}->[$i]) ? $sth->{PRECISION}->[$i]: 0); push(@right_justify, ($type == DBI::SQL_NUMERIC() || $type == DBI::SQL_DECIMAL() || $type == DBI::SQL_INTEGER() || $type == DBI::SQL_SMALLINT() || $type == DBI::SQL_FLOAT() || $type == DBI::SQL_REAL() || $type == DBI::SQL_BIGINT() || $type == DBI::SQL_TINYINT())); my $format_names; $format_names .= sprintf("%%-%ds ", $widths[$i]); print $fh (sprintf($format_names, $names->[$i])); } $self->{'widths'} = \@widths; $self->{'right_justify'} = \@right_justify; print $fh "\n"; }
      /NYSDOT/Config/IniFiles.pm
      package NYSDOT::Config::IniFiles; use strict; use warnings; use Config::IniFiles; use Time::Format qw/time_format/; our @ISA = ("Config::IniFiles"); our $VERSION = "0.3"; =head1 NYSDOT::Config::IniFiles A thin wrapper around the OO interface of C<Config::IniFiles>. =head1 VERSION 0.3 =head1 COPYRIGHT NYSDOT, 2003 =head1 AUTHOR Will Coleda (LTI) =head1 METHODS =head2 new This constuctor takes the same arguments at that for C<Config::IniFi +les>. (a hash of -name and value pairs). If an argument of C<-interpolate> (with a valid section name as a va +lue) is passed into the constructor, then we look for a section with the same name as the value of that argument. If present, all parameters declared in that section are considered variables. Any occurances of that parameter name surrounded by %'s i +n a value (not in the paramater name itself) are interpolated with the value of that parameter. Additionally, if this section is present, parameters of the form C<%TIME=yyyymmdd%> will automatically be expa +nded. Anything after the C<=> will be passed to C<Time::Format>. For examp +le, C<%TIME=yymm%> will expand to C<0301> in January, 2003. See L<Time:: +Format> for more details. A new instance of a Config::IniFiles object is created in which: these substitutions are made; the section that defined the interpola +tions is removed; the parameters passed to its constructor do not include C<-interpolate>. If the C<-interpolate> is not present in the original (or referred t +o an invalid section), then no substitutions are done. A warning is em +itted in the case of an invalid section. =cut sub new { my $proto = shift; my %args = @_; my $class = ref($proto) || $proto; my $interpolate = 0; if ($args{"-interpolate"}) { $interpolate = $args{"-interpolate"}; } delete $args{"-interpolate"}; my $obj = $class->SUPER::new (%args); if ($interpolate) { if (! $obj->SectionExists($interpolate)) { warn "invalid interpolation section $interpolate specified"; } my %params; foreach my $param ($obj->Parameters($interpolate)) { $params{$param} = $obj->val($interpolate,$param); } $obj->DeleteSection($interpolate); foreach my $section ($obj->Sections()) { foreach my $param ($obj +->Parameters($section)) { my $val = $obj->val($section,$param); # Explicit parameter substitution foreach my $param (keys %params) { $val =~ s/%$param%/$params{$param}/gi; } # Automatic TIME= substitution. $val =~ s/%TIME=([^%]+)%/time_format($1)/gei; $obj->newval($section,$param,$val); } } } # now, rebless into our own class. bless($obj,$class); } =head2 boolean Similar to C<Config::IniFile>'s C<val> method. Takes an optional parameter to indicate the default if not specified. If the specified section and parameter don't exist, undef is returne +d, unless a default is supplied, it which case it is returned. If the value exists, and is one of C<0>, C<FALSE>, C<NO>, C<OFF>, then the function returns true, otherwise false. (NB: the default value passed in, and the return value, are Perlian true/false values, and not Configian.) =cut sub boolean { my $self = shift; my ($section,$parameter,$default) = @_; defined($section) or die "Must specify section"; defined($parameter) or die "Must specify parameter"; my $val = $self->val($section,$parameter); if (defined($val)) { if ($val =~ /^\s*(0|FALSE|NO|OFF)\s*$/i) { return 0; } else { return 1; } } else { return $default; } } =head1 BUGS If you write the config back out to disk, it will overwrite the para +meterized version, replacing it with a snapshot of the config as you were usin +g it. This is not the right thing to do. So, don't do that. If you set an interpolated parameter to have a value that contains t +he name of another parameter surrounded by C<%>'s, multiple expansions +may occur, depending on ordering. =cut 1;

        Ah, I see, your file Time/Format.pm has nothing to do with the CPAN module of the same name... (that explains a number of things :) — Side note: although you can of course do it - i.e. store your code with a file name/path differing from the module's package name - I would personally advise against doing so. It only confuses people, especially if a public module of the same name already exists...

        As to your actual problem, have you made sure the DBI module is loaded before you're using its constants, as in

        ($type == DBI::SQL_DATE)? 8 : ($type == DBI::SQL_INTEGER and $sth->{PRECISION}->[$i] > 15 )? 10 +: ($type == DBI::SQL_NUMERIC and $sth->{PRECISION}->[$i] > 15 )? 10 +: ...

        In case of doubt, put a use DBI; somewhere near the top of your Format.pm file (btw, you are using the regular CPAN DBI module, are you? :) — That should make the constants known, and thus avoid the "bareword not allowed" errors. (I have no idea why your code apparently did work with 5.8.0, but that'll be a moot point once you have it working again...)