Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Dear monks,

I've tried a sample program using XML::Simple. If the file content is invalid(text file) is given in the XMLin function, the function is quiting the program with an error message, Instead I need it to return to the program with some error notification(undef/-1). Is it possible?

use strict; use warnings; use XML::Simple; use Data::Dumper; my $xs = new XML::Simple(); my $ref = $xs->XMLin("./system.txt"); # Not an xml file. if (not defined $ref) { print "Invalid content in file"; } else { print "\nHash dump:\n"; print Dumper($ref); }

In reply to XML::Simple - Invalid file content by nagalenoj

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • 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, 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, 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    [erix]: when I capture test-ouput with 2>&1 > test.out why do I still get output on the screen? (I had not expected that)
    [erix]: Hi Corion
    [erix]: ( postgres has adopted TAP tests + perl for testing, and I'm playing around with that )
    [Corion]: erix: Maybe the program re-opens STDERR or something like that? Also, I think you need to redirect first and then do the 2>&1 thing, but I never know and have to Google that
    [huck]: erix some things also write to the raw console/tty/pty rather than stdout/stderr
    [Discipulus]: see this useful site
    [erix]: hm. ok. Either might be the case here. I guess I need to try out more

    How do I use this? | Other CB clients
    Other Users?
    Others chanting in the Monastery: (11)
    As of 2017-03-23 08:15 GMT
    Find Nodes?
      Voting Booth?
      Should Pluto Get Its Planethood Back?

      Results (284 votes). Check out past polls.