Hi monks. Am struggling to understand whats happening here. I have an array of about 50 elements that contain strings inside them. Each element is made up of a many sentences together. I know what is inside and i know 4 of those elements start with the words "The website has been restructured". Now, i have got a loop and a regex to remove the elements of the array that start with these words. For some reason it removes 2 of the elements and it leaves the other 2. I have tried various things like removing 1 from my $value variable when i meet such a case or remove the ^ so that whenever it would meet this in the string it would remove the element but still nothing. For some reason only 2 of the 4 elements are removed. I don't know if this will be of any help but the 4 elements are one after another. Your help will be greatly appreciated
$value = 0; foreach my $text2(@text) { if ($text2 =~ m/^The website has been restructured/) { splice(@text,$value,1); } $value++; }

In reply to Regexp works with some elements and doesn't with others by lampros21_7

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.