Good Morning Wise Monks,
I'm having a bit of XML::Simple problems. I keep getting an error 'Unrecognised option: NoAttr at C:\web\paging\pref2.cgi line 58'. It says that for every option, no matter which I use. I'm on a windows 2000 box running ActivePerl-5.8.0.806-MSWin32-x86. Here's the code.
#! C:\perl\bin\perl.exe
use strict;
use CGI;
use CGI::Carp qw(fatalsToBrowser);
use XML::Simple;
my $path = "C:\\web\\paging\\user_pref";
# New cgi
# Some Security Holes Plugged
$CGI::DISABLE_UPLOADS = 1; # Disable uploads
$CGI::POST_MAX = 1024; # limit posts to 1K max
my $q = new CGI;
# Get and untaint data
my $enter_submits = $q->param('enter_submits');
if ( $enter_submits =~ /^([yes|no]+)$/ ) {$enter_submits = $1}
else {
print "Content-type: text/html\n\n";
print "Only yes and no are legal options!";
exit;
}
###########################
# Update user preferences #
###########################
my $xs = new XML::Simple;
my $User_Preferences = {
'logdir' => '/var/log/foo/',
'debugfile' => '/tmp/foo.debug',
'server' => {
'sahara' => {
'osversion' => '2.6',
'osname' => 'solaris',
'address' => [ '10.0.0.101', '10.0.1.101' ]
},
'gobi' => {
'osversion' => '6.5',
'osname' => 'irix',
'address' => '10.0.0.102'
},
'kalahari' => {
'osversion' => '2.0.34',
'osname' => 'linux',
'address' => [ '10.0.0.103', '10.0.1.103' ]
}
}
};
$xs->XMLout($User_Preferences, AttrIndent => 1, NoAttr => 1, OutputFil
+e => "$path\\$ENV{'LOGON_USER'}.xml");
# print webpage .....
Any help would be greatly appreciated.
Update: Figured it out. Was reading the wrong documentation. Got the right docs from activestate and viole!
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.