... split it to bytes.

If this means you want to end up with an array (or string) of byte values for each pair of hex digits, consider pack:

c:\@Work\Perl>perl -wMstrict -MData::Dump -le "my $s = '00000FFEDFF6'; print qq{'$s'}; ;; my @bytes = split '', pack 'H*', $s; dd \@bytes; " '00000FFEDFF6' ["\0", "\0", "\17", "\xFE", "\xDF", "\xF6"]

Update: Another validation test to make sure you have an even number of hex digits in the source string might also be a good idea.


In reply to Re^3: Regex String by AnomalousMonk
in thread Regex String by egal

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.