The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Simple regex problem? muay_tb Shell Programming and Scripting 1 03-31-2009 10:49 PM
Simple Add - Problem niceboykunal123 Shell Programming and Scripting 5 08-19-2008 05:42 AM
Simple script problem FiniteRed Shell Programming and Scripting 6 08-01-2008 12:15 PM
Simple multiplication problem greekozz UNIX for Dummies Questions & Answers 8 07-06-2007 10:32 AM
Simple ksh script problem Warrior232 Shell Programming and Scripting 14 09-10-2005 12:11 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-13-2009
userscript userscript is offline
Registered User
  
 

Join Date: Apr 2009
Posts: 16
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 (permalink)  
Old 05-13-2009
durden_tyler's Avatar
durden_tyler durden_tyler is offline Forum Advisor  
Registered User
  
 

Join Date: Apr 2009
Posts: 536
Install XML::Simple by using the "cpan" command as root.

tyler_durden
  #3 (permalink)  
Old 05-13-2009
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,957
Place the installed directory - where XML::Simple is installed in perl lib env variable. eg: PERL5LIB
  #4 (permalink)  
Old 05-14-2009
Yogesh Sawant's Avatar
Yogesh Sawant Yogesh Sawant is offline Forum Staff  
Part Time Moderator and Full Time Dad
  
 

Join Date: Sep 2006
Location: Rossem, Tazenda
Posts: 1,086
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 (permalink)  
Old 05-14-2009
userscript userscript is offline
Registered User
  
 

Join Date: Apr 2009
Posts: 16
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 (permalink)  
Old 05-14-2009
userscript userscript is offline
Registered User
  
 

Join Date: Apr 2009
Posts: 16
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
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 12:35 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0