Something I use sometimes is the Data::Dumper module. It helps especially with complex lists, e.g. hashes of hashes of hashes, but the same concept applies here. By using it, you can literally see how contents of variables change, or even if the original values are what you expect them to be.

In this case, for example, you could modify the code to be -

use Data::Dumper; .... <snip> .... if ($text2 =~ m/^The website has been restructured/) { print "text array before is " . Dumper(\@text, $value); splice(@text,$value,1); print "text array after is " . Dumper(\@text, $value); splice(@links,$value,1); }

This way, you can see for yourself how @text is changing, and how it's different from what you expect. Note that you have to pass a reference to a list to the Dumper function call, since @text is one of two elements in the list of things you want to show.

Although you have to go through and uncomment/delete the Dumper lines once you've got it working, if you like actually 'seeing' changes as they happen, this may work very well for you, especially once you start using complex data structures.


In reply to Re^3: Regexp works with some elements and doesn't with others by bowei_99
in thread 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.