Perl error

Q

quartet

Can someone tell me why this script is failing with, "Use of
uninitialized value in string at ./xmldoc line 16."


use XML::Simple;
#use Data::Dumper;
#use Carp;

my ($xml,$data);

$xml = new XML::Simple;

$data = $xml->XMLin("/tmp/config.xml");
#print Dumper($data)

print "$data->{PostBindUID}";
 
A

A. Sinan Unur

Can someone tell me why this script is failing with, "Use of
uninitialized value in string at ./xmldoc line 16."

The subject line of your post is incorrect. It should have been
"programmer error".
use XML::Simple;
#use Data::Dumper;
#use Carp;

use strict;
use warnings;

missing.
my ($xml,$data);

$xml = new XML::Simple;

$data = $xml->XMLin("/tmp/config.xml");

Did this call succeed? You are the only one who can know but you choose
not to tell us. What are we to do?
#print Dumper($data)

print "$data->{PostBindUID}";

Please read the posting guidelines for this group and follow the steps
suggested in that document when posting here.

Sinan.
 
S

Sherm Pendley

quartet said:
Can someone tell me why this script is failing with, "Use of
uninitialized value in string at ./xmldoc line 16."

The script you posted is twelve lines long, therefore there is no line 16 to
have an error. Please post your real script.

sherm--
 
P

Peter Wyzl

: @z14g2000cwz.googlegroups.com:
:
: > Can someone tell me why this script is failing with, "Use of
: > uninitialized value in string at ./xmldoc line 16."
:
: The subject line of your post is incorrect. It should have been
: "programmer error".
:
: > use XML::Simple;
: > #use Data::Dumper;
: > #use Carp;
:
: use strict;
: use warnings;
:
: missing.

At least 'use strict;' must exist in the real script, hence the error.
However, as Sherm pointed out, this script has only 12 lines so is not the
same as that generating the error.

I suspect the absence of 'my' in front of $data is the cause of this
specific error, but as you point out, there are other things wrong too....

P
 
T

Tad McClellan

Peter Wyzl said:
: @z14g2000cwz.googlegroups.com:
:
: > Can someone tell me why this script is failing with, "Use of
: > uninitialized value in string at ./xmldoc line 16."

: use strict;
: use warnings;
:
: missing.

At least 'use strict;' must exist in the real script, hence the error.


That is wrong on at least 2 counts.

First, it is a warning, not an error.

I suspect the absence of 'my' in front of $data is the cause of this
specific error,


Second, the message has nothing to do with strictures.
 
T

Tad McClellan

quartet said:
uninitialized value in string at ./xmldoc line 16."
^^^^^^^

[snip 12-line program]
^^^^^^^


Please do not lie to us.

Please do not waste our time.

Please post the actual failing code if you want help
fixing the failed code.
 
Q

quartet

Sorry for the delay, I thought I would receive an email once i got a
response to my question. The code that was posted is the actual code,
there isn't another mystery script. I figure out the problem though, it
appears that the function, "KeyAttr=>'sku'" was need for accessing the
complex data structure in memory, as far as line '16' I have no idea
why the script was complaining on this, here is the finshed code that
appears to be working:

#!/usr/bin/perl -wT
use strict;

use XML::Simple;
use Data::Dumper;
use Carp;

my ($xml,$data);

#$xml = new XML::Simple (ForceArray => 1);
$xml = new XML::Simple (KeyAttr=>'sku');

$data = $xml->XMLin("/tmp/config.xml");
#print Dumper($data);

print "$data->{UnixMachine}->{PostBindUID}\n";
 
T

Tad McClellan

quartet said:
Sorry for the delay, I thought I would receive an email once i got a
response to my question.


Why did you think that?

This is Usenet.

Usenet is not email.

email is not Usenet.

appears that the function, "KeyAttr=>'sku'" was need


That is NOT a "function".
 
J

Jürgen Exner

quartet said:
I meant attribute.

Did you mean Perl attribute or attribute error?
At least that's the only two possibilities I can find based on the subject
and body of your posting.

Might be good to provide some context about what you are talking about, too,
instead of just throwing 5 words into the NG.

jue
 
T

Tad McClellan

quartet said:
As a followup to Tad was saying,


If you quote some context, like everybody else does, then it
would have been clear from the start without this round-and-round.

Here is the context taken from my followup:
appears that the function, "KeyAttr=>'sku'" was need

That is NOT a "function".

I was meaning perl attribute,


No you weren't, "KeyAttr=>'sku'" is not a perl attribute, it
was a pair of arguments that you passed to the XML::Simple
constructor.

The "Attr" in "KeyAttr" refers to an *XML* attribute.

(but the module docs say it should be "keyattr")

in
correcting myself.


You have not done that yet...



Post one more time without quoting any context and your posts
will become eternally invisible.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,166
Messages
2,570,907
Members
47,446
Latest member
Pycoder

Latest Threads

Top