Hi Monks

I am trying to split a string into three parts. However, I am finding it difficult to come up with the appropriate pattern to help me split this string. Hence, could any monk kindly him me figure this out?

-MEMADDR- ----HEX REPRESENTATION---- ---ASCII--- 0000 21 74 63 5f 37 5f 31 5f 36 !tc_7_1_6

my($memAddr, $data, $ascii); open(DATAFILE $filename) while(<DATAFILE>) { my $line = $_; ($memAddr, $data, $ascii) = split(/PATTERN/, $line);
I am trying to get a pattern the will result to me having the following values

$memAddr = 0000; $data = 2174635f375f315f36; # I think I need join() to get this for +mat $ascii = !tc_7_1_6

I will highly appreciate a help for any Monk out there.


In reply to Splitting a string in Perl by gzayzay

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.