Perl - problem with CPAN module XML::Simple


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Perl - problem with CPAN module XML::Simple
# 1  
Old 05-13-2009
Perl - problem with CPAN module XML::Simple

Hi All,

I am trying to run the following program
Code:
#!/usr/bin/perl
# use module
use XML::Simple;
use Data::Dumper;
 
# create object
$xml = new XML::Simple;
# read XML file
$data = $xml->XMLin("dump.xml");
# print output
print Dumper($dump);

At first i had the error mesage saying can't locate simple.pm. So i downloaded simple.pm and put it in /perl/site/lib/XML folder. I ran the program again and this is what i get
Code:
Can't locate object method "new" via package "XML::Simple" (perhaps you forgot t
o load "XML::Simple"?) at dump.pl line 9.

Not sure what is missing now. Appreciate help

Thanks in adavance

Last edited by Yogesh Sawant; 05-14-2009 at 02:01 AM.. Reason: added code tags
# 2  
Old 05-13-2009
Install XML::Simple by using the "cpan" command as root.

tyler_durden
# 3  
Old 05-13-2009
Place the installed directory - where XML::Simple is installed in perl lib env variable. eg: PERL5LIB
# 4  
Old 05-14-2009
simple method to install XML::Simple:
Code:
perl -MCPAN -e 'install "XML::Simple"'

how do you check if XML::Simple is installed? try using it:
Code:
perl -e 'use XML::Simple;'

# 5  
Old 05-14-2009
Thanks all for your replies.

I installed Simple.pm on my machine. I have the admin rights on my desktop.

I used the command yogesh mentioned. For the options i didnt know answers to, i just ressed enter. Finally i got

commit: wrote C:\Perl\lib\CPAN\Config.pm

I'm thinking it means that it is installed

I also used the command that yogesh mentioned to check if it is installed. I got the following

C:\>perl -e 'use XML::Simple;'
Can't find string terminator "'" anywhere before EOF at -e line 1.
C:\>perl -e "use XML::Simple;"
C:\>


I changed single quotes to double quotes and then it went to the prompt again. So i'm guessing all is OK.

I tried running my program again and the error is the same

Can't locate object method "new" via package "XML::Simple" (perhaps you forgot t
o load "XML::Simple"?) at dump.pl line 9.

Dont know what i missed now. Appreciate help.
# 6  
Old 05-14-2009
grouptags

Hi All,

My issue is resolved. I used ratlperl instead of perl and it resolved my problem.

Thanks for all ur help.

I have redirected the output of my file to output.xm which is in the following format

RT
=> {
'List' => {
'String' => [abcd
efgh
]

RT!
=> {
'List' => {
'String' => [
pqrs
lmno
]


I am trying to get the String values under RT and here is the code i am using

my $data = XMLin("output.xml", GroupTags=>{RequestedTerminations=>'String'});
# print output
print Dumper($data);


However, it doesnt seem to work and i get the following error

Undefined subroutine &main::XMLin called at dump.pl line 15.

Appreciate your help with this
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Proxy Server

Problem with Installing Perl Module in Fedora 20

Hi, I have downloaded Audio::Beep. I tried to install it through CPAN but i got YAML error. Then I have tried to install it manually. I tried all the instructions provided in README file. It worked but when i am compiling , it still gives me error: # ls acct21.pl~ imap(2).pl ... (15 Replies)
Discussion started by: zak100
15 Replies

2. Shell Programming and Scripting

Unable to install module using cpan

Hi, I am unable to install module using cpan. It says 407 Proxy Authentication Required I did setup proxy server and given username and password in .bashrc file and apt.conf file. export http_proxy=http://username:password@proxyserver:portno/ However, still unable to install... (1 Reply)
Discussion started by: Anjan1
1 Replies

3. Shell Programming and Scripting

problem during perl module installation

Hi 'm getting error while installing perl mdule on linux.can any one tell me how to resolve that error? problem is: CPAN: File::Temp loaded ok (v0.22) CPAN.pm: Going to build J/JD/JDB/Win32-OLE-0.1709.tar.gz OS unsupported Warning: No success on command Warning (usually harmless):... (1 Reply)
Discussion started by: kavi.mogu
1 Replies

4. AIX

Perl Module (XML:DOM) dependency

Hi All, I am facing dependency on AIX :confused:.I am trying to run an script which requires PERL MODULE (XML::DOM) to be installed. Please find the attached file which shows the error i am getting (cant locate XML/DOM.pm in @INC). Please let me know how to install PERL MODULE (XML::DOM) ... (3 Replies)
Discussion started by: srivatsa86
3 Replies

5. OS X (Apple)

Unable to install Perl module via CPAN

Hi, I am trying to install Unicode::String from the cpan shell, and here is what I get: Checking if your kit is complete... Looks good Writing Makefile for Unicode::String cp String.pm blib/lib/Unicode/String.pm cp lib/Unicode/CharName.pm blib/lib/Unicode/CharName.pm... (3 Replies)
Discussion started by: psychomachine
3 Replies

6. Shell Programming and Scripting

Where to find 64-bit based perl module like XML::Parser::Expat?

Q: Where to get a 64 bit Expat.so? I run a perl script and got this error: Can't load '/usr/perl5/vendor_perl/5.8.4/i86pc-solaris-64int/auto/XML/Parser/Expat/Expat.so' for module XML:parser::Expat: ld.so.1:myPerl: fatal:... (0 Replies)
Discussion started by: lilili07
0 Replies

7. Shell Programming and Scripting

Facing problem in XML::parser module in PERL

HI, I have XML file which is having values as Spanish character (UTF-8 encoding). I am using XML::parser module but my code is not able to read those characters. I did goggling but not able to find suitable solution. Anybody please help me out. XML file having characters like: ñ I am... (1 Reply)
Discussion started by: jatanig
1 Replies

8. Shell Programming and Scripting

[Perl] How to install with CPAN specified version of module

Hello all, i am searching how to install a module but the question is : howto specify CPAN to install a determined version of the module ? In my case i want to install DBD:Oracle1.14 and not version 1.23 proposed ! Any idea welcome ! :rolleyes: Thanks ! (1 Reply)
Discussion started by: sun_cracker
1 Replies

9. UNIX for Advanced & Expert Users

Apache module & perl problem

I have a very strange problem that I can't seem to solve. I have apache module which filters content and within that module I will add some more content based on this calls: int check; check = system("/usr/bin/check"); check is a perl-script that exits with value 1 if the file doesn't... (2 Replies)
Discussion started by: hjalle
2 Replies

10. Tips and Tutorials

PERL & CPAN Intro for Newbies

So you want to learn a unix scripting language that you'll be able to use in any situation? Perl is your answer ! This is a little intro to installing CPAN modules. If you don't know what CPAN is, check out http://search.cpan.org/. Basicly, it is a massive archive of perl libraries that will... (0 Replies)
Discussion started by: obitus
0 Replies
Login or Register to Ask a Question