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

Greetings,

I recently upgraded my version of perl to ActivePerl 5.6.1 (from 5.6.0), but now I seem to have a problem with code that used to work in 5.6.0...

The code all comes from a module I'm writing for a project I'm working on, this should be all the important code.

sub new { my $class = shift; if(ref $class){ $class->{_errstr} = "Unable to generate object from within objec +t"; return; } my %acess = @_; my $self = {_settings => 0,_divdir => 0, _divlist => 0,_members => +0,alog => ''}; #Preload any files they specify a need for #List of keys: # divisions # memberlist my($settings,$memblist,$path); croak "Unable to locate GMSSettings.gms in current path" unless(-e +"GMSSettings.gms"); $settings = new IniFile("GMSSettings.gms"); $path = $settings->get(['FILE','MEMBERDIRL'], -mapping => 0); if($acess{'divisions'} && $settings->get(['OTHER','DIVISIONS'], -ma +pping=>'single') ){ if(-e "$path/division.gms" && -e "$path/divlist.gms"){ $self->{_divdir} = new IniFile("$path/division.gms"); $self->{_divlist} = new IniFile("$path/divlist.gms"); }else{ croak "Unable to locate division.gms and/or divlist.gms in $p +ath"; } } if($acess{'memberlist'}){ if(-e "$path/memberlist.gms"){ $self->{_members} = new IniFile("$path/memberlist.gms"); }else{ croak "Unable to locate memberlist.gms in $path"; } } if($settings->get(['FILE','LOGACTION'],-mapping=>'single')){ local *LOGFILE; open(LOGFILE,">>$path/GMS.log") or croak("Unable to open logfile +! $!"); $self->{alog} = \*LOGFILE; my $temp = $self->{alog}; } $self->{_settings} = $settings; my $object = bless($self,$class); $GMS::LIVEOBJECT = $object; return $object; } sub logaction{ my $self = ref($_[0]) ? shift : 0; croak("Logaction is a METHOD. GMS object required.") if(!ref($self +)); return(1) unless($self->{_settings}->get(['FILE','LOGACTION'],-mapp +ing=>'single')); my $file = $self->{alog}; unless($file){ $self->{_errstr} = "Log not open!"; return; } my($uid,$ip); if($_[1] && $_[1] !~ m/\D/go){ $uid = $_[1]; }else{ my $temp = $self->verifylogin(); $uid = $temp->[1] || "???"; } $ip = $ENV{'REMOTE_ADDR'} || '???'; my $action = $_[0]; $action =~ s/\n|\r/<BR>/go; flock($file,2) if($self->getsetting('OTHER','FLOCK')); seek($file,0,2); print $file time.";$ip;$uid;$action\n";# or warn("UNABLE TO LOG!\n$ +!"); flock($file,8) if($self->getsetting('OTHER','FLOCK')); return(1); }


This is what happens when I try to test the code (does the same thing within the programs that are suppost to use it):
E:\Apache\cgi-bin\GMS>perl -w -e "use GMS; my $GMS = new GMS; $GMS->lo +gaction('test') or die($!);" seek() on unopened filehandle GMS::LOGFILE at GMS.pm line 271. print() on unopened filehandle GMS::LOGFILE at GMS.pm line 272. (in cleanup) Can't call method "EXISTS" on an undefined value at E: +/Perl/site/lib/IniFile.pm line 375 during global destruction.


If you need more information on anything, please just say so.

Thanks


-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GIT d- s:++ a--- C++++ UL P+++>++++ L+ E- W++>+++ N !o K- w+ O---- M-- V--
PS PE Y- PGP t++(+++) 5(+++)++++ X R+@ tv+ b+++ DI+ D- G e->+++ h! r-- y-
------END GEEK CODE BLOCK------
Translate

"Weird things happen, get used to it."

Flame ~ Lead Programmer: GMS

Edit by tye
Edit kudra, 2002-01-10 Changed title per ntc request

Replies are listed 'Best First'.
Re: ActivePerl 5.6.1?
by ralphie (Friar) on Jan 10, 2002 at 18:10 UTC
    have you tried tracing through things in a debugger? you might be able to find where things are broken by periodically evaluating statements as you move through the code.
      How would I use the debugger to do that? (I haven't been able to make any sense of it so far...)

      Thanks for the suggestion


      -----BEGIN GEEK CODE BLOCK-----
      Version: 3.12
      GIT d- s:++ a--- C++++ UL P+++>++++ L+ E- W++>+++ N !o K- w+ O---- M-- V--
      PS PE Y- PGP t++(+++) 5(+++)++++ X R+@ tv+ b+++ DI+ D- G e->+++ h! r-- y-
      ------END GEEK CODE BLOCK------
      Translate

      "Weird things happen, get used to it."

      Flame ~ Lead Programmer: GMS

        Try perldebug. And if you have the Camel book, there's a whole chapter there on using the debugger.

        Rich36
        There's more than one way to screw it up...

Re: Problems with unopened filehandle after upgrade to ActivePerl 5.6.1
by Flame (Deacon) on Jan 11, 2002 at 02:36 UTC
    Afer some experementation with sleep and a file monitor, I have to conclude it close immediately after this block..

    if($settings->get(['FILE','LOGACTION'],-mapping=>'single')){ local *LOGFILE; open(LOGFILE,">>$path/GMS.log") or croak("Unable to open logfile +! $!"); print STDERR "Opening!"; sleep 5; $self->{alog} = \*LOGFILE; my $temp = $self->{alog}; }


    Something to to with the local declaration? Is there any other way to keep the filehandle from interfering with others of the same name that might be used?

    Thanks


    -----BEGIN GEEK CODE BLOCK-----
    Version: 3.12
    GIT d- s:++ a--- C++++ UL P+++>++++ L+ E- W++>+++ N !o K- w+ O---- M-- V--
    PS PE Y- PGP t++(+++) 5(+++)++++ X R+@ tv+ b+++ DI+ D- G e->+++ h! r-- y-
    ------END GEEK CODE BLOCK------
    Translate

    "Weird things happen, get used to it."

    Flame ~ Lead Programmer: GMS

      Try changing this line:
      $self->{alog} = \*LOGFILE;
      To this:
      $self->{alog} = *LOGFILE;
      And let me know if it works....

      -Blake

        That did it, I don't understand why though... did they change something that I didn't catch in the docs? It was always working fine like that before...


        -----BEGIN GEEK CODE BLOCK-----
        Version: 3.12
        GIT d- s:++ a--- C++++ UL P+++>++++ L+ E- W++>+++ N !o K- w+ O---- M-- V--
        PS PE Y- PGP t++(+++) 5(+++)++++ X R+@ tv+ b+++ DI+ D- G e->+++ h! r-- y-
        ------END GEEK CODE BLOCK------
        Translate

        "Weird things happen, get used to it."

        Flame ~ Lead Programmer: GMS