What did you expect this line of your code to do?
chomp($node); chomp($filename);
If you read the output of 'perldoc -f chomp', you will see that in effect it does  s{ \Q $/ \E $ }{}x on each of the args that you give it; that is, if a string ends with the character (sequence) that is the current value of the global INPUT_RECORD_SEPARATOR variable, then chomp removes that character (sequence) from the end of the string.

When you read file names from a directory via glob() or readdir() (or File::Find), they do not come with newlines at the end of each name -- directory entries normally do not contain linefeed or CRLF as part of the file name.

Apart from that, you seem to be "populating the hash" from scratch, loading exactly one element into the hash each time, at every iteration of the foreach loop -- the hash never has more than one element in it:

%needs_desc = ("$node" => 1);
and then you're printing that one element if the filename happens to differ from your target pattern, also at every iteration of the foreach loop. I think the other replies above have already pointed you in a better direction.

In reply to Re: Regex Basics by graff
in thread Regex Basics by mbeason

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.