Thanks for all your inputs. @stevieb: I think the problem is at line 50 in the file which I am guessing from the error I see after adding :encoding(UTF-8) in filehandle at line 17 which now looks like open(my $fh, "<:encoding(UTF-8)", "20150626102938.txt")

(Thanks to AnomalousMonk for sugestion)

I am on perl v5.10.1 at present and will see if can get it upgraded but it'll be a while before I can get it done.

@AnomalousMonk: I was trying to do this

perl -pe's/\x08//g' <20150625163139.xml >20150625163139.xml

from the code. And I tried using two different file names as well. I just kept getting same error so just left it there. But if I can get it working, then I'll ensure to use two different files there.

I am sorry for causing confusion about 20150625163139.xml. It is just an existing text file (generated at run time) which I have to use to generate xml. I can change it's extension to .txt though.

I tried adding

:encoding(UTF-8)

in filehandle at line 17 which now looks like

open(my $fh, "<:encoding(UTF-8)", "20150626102938.txt")

Before adding the output of script was:

Code point \u0016 is not a valid character in XML at ./Call_to_snmpwal +k_V_1.pl line 34

After adding the output of script was:

utf8 "\xB8" does not map to Unicode at ./Call_to_snmpwalk_V_1.pl line +35, <$fh> line 50. utf8 "\xF3" does not map to Unicode at ./Call_to_snmpwalk_V_1.pl line +35, <$fh> line 50. Code point \u0016 is not a valid character in XML at ./Call_to_snmpwal +k_V_1.pl line 34

@sundialsvc4: I am sorry for confusion caused by 20150625163139.xml It's just text file with no <?xml version="1.0" encoding="UTF-16" standalone="no"?> at the top I tried adding that tag manually at the top in file 20150625163139.xml just to give it a try but it still gives same error with and without :encoding(UTF-8) added in filehandle

@afoken: Thanks for adding the context link.


In reply to Re^2: How to remove error: Code point \u0016 is not a valid character in XML by Perl300
in thread [Solved]:How to remove error: Code point \u0016 is not a valid character in XML by Perl300

Title:
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, 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:
    & &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.