I am having a problem with the value in one of my scalar variables. There seems to be a carriage return in it and additional blank spaces, but I can't seem to remove them. I have tried the following lines:
chomp $name; $name =~ s/^(.*)(\b|\W)/$1/;
but it doesn't remove whatever is after the part I can see.

For example, the value in my scalar is '12345 \t \n ' Now of course I cannot see the tab and new line characters so I am not positive what is after the '12345' I am looking for a way to turn this value into a HEX string so I can see it says something like '30 31 32 33 34 35 20 20 20 20 09 20 20 0D 20 20 20'.

Is there an easy way to do this so I can remove the extra stuff at the end?


In reply to Converting decimal value to hex by coldmiser

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.