Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re^3: list files based on age and pattern

by hdb (Prior)
on Sep 16, 2013 at 13:24 UTC ( #1054295=note: print w/replies, xml ) Need Help??

in reply to Re^2: list files based on age and pattern
in thread list files based on age and pattern

That is, because you are doing closedir before readdir. If you were running under use warnings;, Perl would have given you an error message like

readdir() attempted on invalid dirhandle $dh at line 5.

Replies are listed 'Best First'.
Re^4: list files based on age and pattern
by kaka_2 (Sexton) on Sep 16, 2013 at 13:56 UTC
    Hello hdb,

    Sorry it is mistake while copy paste but in the actual script closdir is after the readdir.

    there is no syntax or compilation error, only no files.


      My fault. You need to add the path to the filename when testing with -M like this

      my @files = grep {!/\_NSA|d+_\d+\.xml/ && (-M "$path/$_") > $min_age} readdir DIR;

      I only tested in the current directory where it does not make any difference.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1054295]
Discipulus Good day bros?!? oh tempora oh mores!
[amitkumarj441]: Hey everyone
[amitkumarj441]: I need to ask a question, where can I post my problem?
[Discipulus]: everyone is me
[Discipulus]: Seekers of Perl Wisdom is the for asking question
[Discipulus]: be sure to use code tags for code and data
[Discipulus]: and to show some effort while asking
[Discipulus]: <code> code and data</code>

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (7)
As of 2017-04-26 20:19 GMT
Find Nodes?
    Voting Booth?
    I'm a fool:

    Results (488 votes). Check out past polls.