Just another Perl shrine | |
PerlMonks |
Re: File searching *by davido (Cardinal) |
on Mar 02, 2020 at 03:33 UTC ( [id://11113616]=note: print w/replies, xml ) | Need Help?? |
You could change your conditional as follows:
You have this, currently: $entry5 ne '<*.log>', which doesn't really make sense. You clearly are not looking for a file named <*.log> but you are specifying exactly that within single quotes, which prevent the glob operator from doing anything useful. Additionally you don't really need the glob operator, they way you are testing the files. There's another puzzler in your code as well: What filename would match $name . '.log' but would not match *.log or m/\.log$/? What I'm getting at is that there doesn't seem to be any good reason to test explicitly for $name, since the part of the conditional to the right of the && operator would already catch everything that ends in .log. One thing also to bring up: You could probably avoid the readdir and while loop entirely by using the glob operator correctly:
This may or may not be exactly what you're after, but it's what your code seems to be trying to do. Dave
In Section
Seekers of Perl Wisdom
|
|