[mapserver-users] Problems with Perl mapscript and save()

Puneet Kishor pkishor at GeoAnalytics.com
Wed Nov 13 21:50:43 EST 2002


On Wednesday, November 13, 2002, at 03:55  PM, 
Jean-Francois.Doyon at CCRS.NRCan.gc.ca wrote:

> Hello,
>
> I'm trying to run a batch process on a bunch of mapfiles, so I wrote a
> little perl/mapscript script to help me along (Find it below).
>
> I'm having 2 problems, one seems to have something to do with 
> re-entrancy
> and the destruction/creation of the object, and the other with the 
> save()
> function.
>
> Here is the output I get when I run my script:
>
> [root at grumbler root]# ./mapfiledit.pl -d english/ -w newmapfiles/
> english/10.map
> newmapfiles/10.map
>         (in cleanup) Not a HASH reference at
> /usr/lib/perl5/site_perl/5.6.1/i386-linux/mapscript.pm line 2415.
>


from a recent thread on this topic, here is Joe Bussell's reply that 
works (Lowell and a few others had helped me with this a while back as 
well) --

===
The cleanup errors are due to a poorly written interface to SWIG.  The
code that connects PERL to the underliing C functionality creates ties
using perl hashes.  Some interconnects are not proper hashes.  I have no
idea why at this point, but I do know a hack that will eliminate the
cleanup warnings.  In your mapscript.pm file everywhere you find a
DESTROY method you should return directly if the input is not a hash.  I
offer the following example:

sub DESTROY {
    return unless $_[0]->isa('HASH');
    my $self = tied(%{$_[0]});
    delete $ITERATORS{$self};
    if (exists $OWNER{$self}) {
       mapscriptc::delete_rectObj($self);
       delete $OWNER{$self};
    }
}
===

the above replace is in about 5-6 different places in mapscript.pm.

That will take care of that.




More information about the mapserver-users mailing list