Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^2: Getting modification time in perl not working on my MAC

by hary536 (Novice)
on Mar 21, 2014 at 16:36 UTC ( #1079296=note: print w/ replies, xml ) Need Help??


in reply to Re: Getting modification time in perl not working on my MAC (because i'm a stupid noob)
in thread Getting modification time in perl not working on my MAC

Hi, Thanks for your reply. I was copying and pasting the main code out of my file here(omitting the extra comments I have in my file). I had modified variable names in my main code but not in the comments. Though, with all the variables correct, it is still not working. -M command is working if it is between the opendir and closedir lines. If -M is outside anywhere it is not working. I am trying to compare the modification time of the latest modified file against the current time and make some decision if the time difference is more than 30 minutes. Any suggestions? Thanks.


Comment on Re^2: Getting modification time in perl not working on my MAC
Re^3: Getting modification time in perl not working on my MAC
by hary536 (Novice) on Mar 21, 2014 at 17:03 UTC
    Correction to my previous statement. -M option works as long as that line is before the sort line. IF I use it after the sort line, it gives that uninitialized message. I don't understand why. Thanks.
      Yeah, because $moviedir[1] is a ".."
Re^3: Getting modification time in perl not working on my MAC
by Anonymous Monk on Mar 21, 2014 at 22:38 UTC

    Though, with all the variables correct, it is still not working. -M command is working if it is between the opendir and closedir lines

    Well you have  -M $moviedir[1] and  -M "$CosMovFolder/$moviedir[1]" its the basic stumbling block of readdir that everyone stumbles on .

    readdir is just low level api ... low level api are a pain

    use Path::Tiny its easy

    use Path::Tiny qw/ path /; my @sorted_files = map { $$_[1] } sort { $$a[0] <=> $$b[0] } map { [ $_->stat->mtime, $_ ] } path( $CosMovFolder )->realpath->children();

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1079296]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (10)
As of 2014-07-29 19:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (226 votes), past polls