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

I'm building a new Squeeze server to replace an Etch one, and have 2 problems with an existing script. Not being a Perl expert (or even close!), I've had a poke around but can't find the cause. 1st is
Unable to recognise encoding of this document at /usr/share/perl5/XML/ +SAX/PurePerl/EncodingDetect.pm line 100
It's very worth mentioning that I get this in the apache2 log when I restart Apache2, so could indicate a wrong/missing package Installed xml packages:
ii libexpat1 2.0.1-7 + XML parsing C library - runtime library ii libxml-dumper-perl 0.81-1 + Perl module for dumping Perl objects from/to XML ii libxml-grove-perl 0.46alpha- +12 Perl module for accessing parsed *ML instances ii libxml-libxml-perl 1.70.ds-1 + Perl interface to the libxml2 library ii libxml-namespacesupport-perl 1.09-3 + Perl module for supporting simple generic namespac +es ii libxml-parser-perl 2.36-1.1+b +1 Perl module for parsing XML files ii libxml-parser-ruby1.8 0.7.1-1.1 + Interface of expat for the scripting language Ruby + 1.8 ii libxml-perl 0.08-2 + Perl modules for working with XML ii libxml-sablot-perl 1.0-2+b1 + encapsulation of the Sablotron XSL processor ii libxml-sax-perl 0.96+dfsg- +2 Perl module for using and building Perl SAX2 XML p +rocessors ii libxml-simple-perl 2.18-3 + Perl module for reading and writing XML ii libxml-twig-perl 1:3.34-1 + Perl module for processing huge XML documents in t +ree mode ii libxml-xpathengine-perl 0.12-2 + re-usable XPath engine for DOM-like trees ii libxml2
2nd is a problem with PDL:
Undefined subroutine &Proj::pj_init called at /usr/share/perl5/Avbrief +/Projection.pm line 88
Line 88 is:
$p->{pj} = Proj::pj_init(4, ["proj=$p->{proj}", "units=$p->{units}", "lat_0=$p->{lat_0}", "lon_0=$p->{lon_0}"]);
I've tried
$p->{pj} = Proj::pj_init_plus(4, ["proj=$p->{proj}", . . .
and get
Undefined subroutine &Proj::proj_init_plus called at /usr/share/perl5/ +Avbrief/Projection.pm
Cheers, Martin

Replies are listed 'Best First'.
Re: SAX and PDL probs
by InfiniteSilence (Curate) on Jan 24, 2012 at 17:54 UTC

    For problem #1 I recommend you include how the code you are calling uses the encoding_detect() function of XML::SAX::PurePerl. If you read the code you'll see that the warning you are seeing appears at the end of the function if none of the conditions it is looking for are satisfied.

    For #2 I don't see any proj_init function:

    pdl> help pj_init No PDL docs for 'pj_init'. Using 'whatis'. (Try 'apropos pj_init'?) 'pj_init'
    So I guess you'll need to show some more code for that one as well.

    Celebrate Intellectual Diversity

      Cheers, this is the top of the script (/avprog/bin/alerting_map_all.pl) that is run:
      #!/usr/bin/perl use strict; use warnings; use Getopt::Long; use Avbrief::AlertingMap; use Avbrief::ProcControl; use Avbrief::DataLayer::CDBI::map_mainframe; use File::Basename; print "start of script"; die "this script must be run as 'abl'\n" unless ('abl' eq getpwuid($<) +); my $logpath = "/var/log/avbrief/".basename($0).".log"; my $timeout = (10 * 60);
      When it's run, I get the errors before the output of the print.
      # sudo -u abl /avprog/bin/alerting_map_all.pl Unable to recognise encoding of this document at /usr/share/perl5/XML/ +SAX/PurePerl/EncodingDetect.pm line 100. Undefined subroutine &Proj::proj_init_plus called at /usr/share/perl5/ +Avbrief/Projection.pm line 89. . . . Undefined subroutine &Proj::proj_init_plus called at /usr/share/perl5/ +Avbrief/Projection.pm line 89. start of script
      Which to me looks like the XML issue is not a script problem but a config/environment problem. Really confused now!!

      In /usr/lib/perl5/PDL/GIS/Proj.pm is the following comment that lead to mention of proj_init_plus
      =head2 1.10 (23 April 2003) Judd Taylor - Changed from using the proj_init() type API in projects.h to th +e - proj_init_plus() API in proj_api.h. The old one was not that st +able...
      /usr/include/proj_api.h
      projPJ pj_init(int, char **); projPJ pj_init_plus(const char *)
      OK, as stopping or starting apache2 gives the XML error, I tried running startup.pl. And got:
      perl /etc/apache2/startup.pl Unable to recognise encoding of this document at /usr/share/perl5/XML/ +SAX/PurePerl/EncodingDetect.pm line 100. Unable to recognise encoding of this document at /usr/share/perl5/XML/ +SAX/PurePerl/EncodingDetect.pm line 100. Apache.pm was not loaded at /etc/apache2/startup.pl line 12 couldn't connect to dbi:Pg:dbname=xxxxx;host=localhost at /etc/apache2 +/startup.pl line 12.
      Reduced startup.pl to
      #!/usr/bin/env perl use strict; use warnings; use lib '/usr/share/perl/5.10.0'; use ModPerl::Registry; # use Apache::Registry; use Apache::DBI; use Apache::AuthDBI; Apache::DBI->connect_on_init('dbi:Pg:dbname=xxxxx;host=localhost', und +ef, undef, { RaiseError => 1, AutoCommit => 1 }) or die "couldn't connect"; 1;
      and get
      perl /etc/apache2/startup.pl Apache.pm was not loaded at /etc/apache2/startup.pl line 13 couldn't connect at /etc/apache2/startup.pl line 13.
      I'm closer to fixing the XML issue, but this one has me stumped! Let me know if this is veering off topic!