How can I add an identifier to differentiate any block of data coming from an array?
I know that the data will come in blocks, I would like to be able to differentiate each block by comparing the first tag <1> with any other first tag in this array, if there is a match I would like to add something like
<1><2><3>...<1b><2b><3b>...<1c><2c><3c><4>...<1d><2d><3d>....
How could I do something like that? Data will be in one or more blocks like these:
<1>66543 <2>2009 <3>TY <4>- <6> <7>TOM <8>2 - DUNDAS <8>100 - MAIN <9>ONT 00001 <10> <11>000-000-0000 <12> <1>12345 <2>1999 <3>PP <4>XLX - TEST <6>Comm <7> <8>1 BLVD <9>MA 00001 <10>CITI, INC. <11>000-000-0000 <12> <1>8887 <2>2000 <3> <4>TEST <6> <7>JOE <7>MARY <8>100 MAIN <9>CT 02221 <10>BH, INC. <11>871-000-0000 <12>YEAR <1>test <2>2087 <3>XX <4>- <6> <7>DOM <8>2 - CHT <8>1000 - CAR <9>ONTA X0001 <10> <11>000-000-0000 <12> <13> <14>CB

my @all; # here is all the data will be foreach my $xy (@all) { }


It would be nice to have at the end something like this:
<1>66543 <2>2009 <3>TY <4>- <6> <7>TOM <8>2 - DUNDAS <8>100 - MAIN <9>ONT 00001 <10> <11>000-000-0000 <12> <1b>12345 <2b>1999 <3b>PP <4b>XLX - TEST <6b>Comm <7b> <8b>1 BLVD <9b>MA 00001 <10b>CITI, INC. <11b>000-000-0000 <12b> <1c>8887 <2c>2000 <3c> <4c>TEST <6c> <7c>JOE <7c>MARY <8c>100 MAIN <9c>CT 02221 <10c>BH, INC. <11c>871-000-0000 <12c>YEAR <1d>test <2d>2087 <3d>XX <4d>- <6d> <7d>DOM <8d>2 - CHT <8d>1000 - CAR <9d>ONTA X0001 <10d> <11d>000-000-0000 <12d> <13d> <14d>CB

Thanks for the help!!

In reply to Adding an identifier to an array element. by Anonymous Monk

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.