in reply to Using the XMLin() method in XML::Simple not working

Is that the exact code, or are you writing from memory? It looks like it should work. The error message you received tells you that the XMLin function was not imported into your namespace.

Are you perhaps loading XML::Simple like this:

use XML::Simple ();

The () tell perl to not import any symbols when loading the module. The easiest way to see if this is your problem is to fully qualify the call to XMLin (which makes your code a lot clearer as well IMO)

$outxmlParsed = XML::Simple::XMLin($1);

Replies are listed 'Best First'.
Re^2: Using the XMLin() method in XML::Simple not working
by heigold1 (Acolyte) on May 31, 2005 at 19:45 UTC
    Hi, thank you for your response.

    I pasted those lines of code in from my script, so that is syntactically how I am loading the package and making the call to XMLin.

    I tried your suggestion of XML::Simple::XMLin($1); but that still didn't work, as this time I get the error:

    Undefined subroutine &XML::Simple::XMLin called at c:\buildscript\Clues1TestScript.pl line 69.

    Any other ideas?

      It's as if the use was never executed, the use failed but the exception was caught, or if it's not loading the module it should load.

      What does
      perl -we "use XML::Simple; print $INC{'XML/Simple.pm'}"
      give you? A warning or a file name?

      If it returns the a file name, can you give us the first 20-50 lines of that file? What follows is the top lines from the newest version, but even as far back 1.06 is very similar

      >perl -we "use XML::Simple; print $INC{'XML/Simple.pm'}" r:/Utils/perl/site/lib/XML/Simple.pm >type "r:\Utils\perl\site\lib\XML\Simple.pm" # $Id: Simple.pm,v 1.23 2005/01/29 04:16:10 grantm Exp $ package XML::Simple; =head1 NAME XML::Simple - Easy API to maintain XML (esp config files) =head1 SYNOPSIS use XML::Simple; my $ref = XMLin([<xml file or string>] [, <options>]); my $xml = XMLout($hashref [, <options>]); Or the object oriented way: require XML::Simple; my $xs = new XML::Simple(options); my $ref = $xs->XMLin([<xml file or string>] [, <options>]); my $xml = $xs->XMLout($hashref [, <options>]); (or see L<"SAX SUPPORT"> for 'the SAX way'). To catch common errors: use XML::Simple qw(:strict); (see L<"STRICT MODE"> for more details). =cut # See after __END__ for more POD documentation # Load essentials here, other modules loaded on demand later use strict; use Carp; require Exporter; ###################################################################### +######## # Define some constants # use vars qw($VERSION @ISA @EXPORT @EXPORT_OK $PREFERRED_PARSER); @ISA = qw(Exporter); @EXPORT = qw(XMLin XMLout); @EXPORT_OK = qw(xml_in xml_out); $VERSION = '2.14'; $PREFERRED_PARSER = undef;

      You are going to have to create a small script that recreates this problem. Remove everything from the script that does not have anything to do with XML::Simple.

      Most likely during that exercise you will notice that you have found/fixed the problem yourself. If not, then show us that script and we should be able to help. Right now you haven't given us enough info to know exactly what is wrong, so we are left to guess.