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.chomp($node); chomp($filename);
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:
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.%needs_desc = ("$node" => 1);
In reply to Re: Regex Basics
by graff
in thread Regex Basics
by mbeason
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |