my @text_remove = ('[TEXT-2]', '[TEXT-4]', '[TEXT-7]'); my @xlate_data = ('[TEXT-1] Data Test ', '[TEXT-2] Second line tacked +onto #1', '[TEXT-3] Line #3', '[TEXT-4] 4th line goes with #3', '[TEX +T-5] five-five-FIVE', '[TEXT-6] Five was a Zappa reference...', '[TEX +T-7] This is a longer entry. But really not much different. I should + be part of #6'); my %text_remove; @text_remove{@text_remove} = @text_remove; foreach my $xlate_pos (1..$#xlate_data) { my $data = $xlate_data[$xlate_pos]; if( $text_remove{($data=~/^(\[[\w-]+\])/)[0]} ){ $data =~ s/^\[[\w-]\]\s*/ /; $xlate_data[$xlate_pos -1] .= $data; $xlate_data[$xlate_pos] = ''; } } @xlate_data = grep{$_}@xlate_data; foreach (@xlate_data) { print "NOW: $_\n"; }

In reply to Re: Reducing Array Interations by I0
in thread Reducing Array Interations by THRAK

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.