Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

You could change your conditional as follows:

if ($entry5 ne $name && $entry5 !~ m/\.log$/) { # ...

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:

if (-e 'abc' && -d _) { foreach my $entry (<*.log>) { print OUTPUT ":E: $entry5 is extra file/dir \n"; } }

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 reply to Re: File searching * by davido
in thread File searching * by michael99

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2024-04-25 13:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found