siddheshsawant has asked for the wisdom of the Perl Monks concerning the following question:
Hello monks, I am trying to print xml type output using perl for which I used XML::Simple module.When I check one value is defined or not like this
sub error_excerpt{ return defined($error_excerpt)?$self->{_error_excerpt}:"No Error Excer +pt."; }
and I print corresponding value in sub print like this:
if(defined $self->error_excerpt()) { printf("\t\tError Excerpt:\t\t%s\n", $self->error_excerpt()); }
I am getting an output
<error_excerpt>No Error Excerpt</error_excerpt>although the error excerpt value is defiened..
One more thing when I used
sub error_excerpt{ $self->{_error_excerpt} = $error_excerpt if defined($error_excerpt); return $self->{_error_excerpt}; }
I gets proper error excerpt value where the error_excerpt is defined and I do not get any value and just gets
<error_excerpt></error_excerpt>where I actually wants to print "No error Excerpt exist"
Can anybody tell me where I am doing mistake?If possible rectify me.Thanks in advance !!!!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Question on XML output using Perl
by almut (Canon) on Mar 16, 2010 at 15:53 UTC | |
by siddheshsawant (Sexton) on Mar 16, 2010 at 16:08 UTC | |
by wfsp (Abbot) on Mar 16, 2010 at 16:16 UTC | |
by siddheshsawant (Sexton) on Mar 16, 2010 at 16:30 UTC | |
by almut (Canon) on Mar 16, 2010 at 16:17 UTC | |
by siddheshsawant (Sexton) on Mar 16, 2010 at 16:29 UTC | |
by Khen1950fx (Canon) on Mar 16, 2010 at 16:34 UTC | |
|
Re: Question on XML output using Perl
by Anonymous Monk on Mar 16, 2010 at 15:38 UTC |