Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re^2: Use of uninitialized value in require at ?

by jvector (Friar)
on Oct 22, 2008 at 08:51 UTC ( [id://718659] : note . print w/replies, xml ) Need Help??

in reply to Re: Use of uninitialized value in require at ?
in thread Use of uninitialized value in require at ?

This is indeed version 5.60 of Autoloader, running under perl 5.8.8.

The first few lines are:

package AutoLoader; use strict; use 5.006_001; our($VERSION, $AUTOLOAD); my $is_dosish; my $is_epoc; my $is_vms; my $is_macos; BEGIN { $is_dosish = $^O eq 'dos' || $^O eq 'os2' || $^O eq 'MSWin32' || $ +^O eq 'NetWare'; $is_epoc = $^O eq 'epoc'; $is_vms = $^O eq 'VMS'; $is_macos = $^O eq 'MacOS'; $VERSION = '5.60'; } AUTOLOAD { my $sub = $AUTOLOAD;

This is the same code as that cited by Anonymous Monk in

Lines 91-2 say:

local $!; # Do not munge the value. eval { local $SIG{__DIE__}; require $filename };
where the previous block (most of the AUTOLOAD sub, in fact) goes to great lengths to establish $filename.

ikegami, I don't believe DDSutils is involved. That just exports a couple of subs and some quasi-constants.No clever BEGIN/END stuff.

I observed that the Autoloader module does not itself use warnings; - I am reminded of another situation in the past where a CPAN module (I don't recall which) peppered my web server error log with warnings when my code ran under #!/usr/bin/perl -w because my invocation was imposing warningfulness on it. . That went away when I replaced #!/usr/bin/perl -w with use warnings; which kept my warnable condition to my own scope. I am just wondering whether something similar could be happening with regard to diagnostics but it seems rather far fetched.

Update: Forgot to say:

This is perl, v5.8.8 built for i486-linux-gnu-thread-multi ; out-of-the-box Ubuntu 8.04 LTS.

This signature will be ready by Christmas

Replies are listed 'Best First'.
Re^3: Use of uninitialized value in require at ?
by jvector (Friar) on Oct 22, 2008 at 09:18 UTC

    I hope it is not considered poor etiquette to follow up on my own message - if so, please excuse this.

    Just seen on perldoc's diagnostics (emphases are in the original):

    (Note that this does enable perl's -w flag.)

    So the throwaway comment on scoping turns out to be relevant after all. Once more the Universe says 'RTFM'.

    I suspect that is probably about it...? Nothing further, your honour.

    This signature will be ready by Christmas
Re^3: Use of uninitialized value in require at ?
by ikegami (Patriarch) on Oct 22, 2008 at 21:05 UTC

    diagnostics is causing the warning to appear, but it's not the cause of the warning. It appears that Autloader is doing require undef;. I'd wonder why.

      Apparently Autoloader is doing require undef; if there is an undef value in @INC when DBI's connect method is called.

      This code generates the warning if the line push  @INC,$ENV{'PERL5LIB'}; is executed before the call to DBI->connect. It's not clear what the push  @INC,$ENV{'PERL5LIB'}; is actually meant to be doing (this code has been copied from a system that was built several years ago).

      The code connects to an Oracle database. Obviously it will not work with someone else's Oracle DB. If you do not have an Oracle database I do not know if the same issue shows up with other DBD drivers. I did see the same Autoloader warning appearing when I ran the code with invalid connect parameters, but don't know what was being complained about.

      #!/usr/bin/perl use strict; use warnings; use diagnostics -warntrace; # the -warntrace does not seem to help B-( use DBI; sub db_connect; my $Odbh; # database handle returned by connect to Oracle print "$0: ",(scalar localtime), "\n"; #exit; #no warn if exit before db_connect call &db_connect; exit; # yes warn if exit after connect print "$0: " ,(scalar localtime), " run complete\n"; $Odbh->disconnect; #exit; # yes warn if exit after connect + disconnect ################ sub db_connect { ################ my ($dsn, $dbuser, $dbpassword) = ("DBI:Oracle:qq3","nn2","nn2"); # # Connect to Oracle # # if the push on the next line is commented out there is no warning. push @INC,$ENV{'PERL5LIB'}; # location of libs for DBD::Oracle print "ENV= [",join ("]\n[",@INC),"]\n"; $Odbh = DBI->connect($dsn, $dbuser, $dbpassword, { RaiseError => 1, AutoCommit => 1 }) or warn "Can't connect to $dsn: $DBI::errstr"; }

      This signature will be ready by Christmas

        If that's true, it's just a little case of GIGO that can be fixed by making the push conditional.

        push @INC, $ENV{'PERL5LIB'} if exists($ENV{'PERL5LIB'});