LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-24-2006, 05:35 AM   #1
Cornholio
Member
 
Registered: Dec 2004
Location: Alemania
Distribution: Slackware 10.0
Posts: 115

Rep: Reputation: 15
[Perl] Files from today or yesterday


Hi there!

I am trying to identify files in a directory by the day, they were created.

My "algorithm" is like that:

Code:
foreach $file (@directory){
   $file_timestamp = (a);
   $today_timestamp = (b);
   if(file_timestamp >= today_time_stamp){
        # here comes more
   } else {
        # file will be ignored
   }
}
Now the 2 problempoints I have are marked with (a) and (b). I found alot of snippets to this topic but it is confusing me right away. I am not that Perl-guru ...

The Questions:

(a) solved.
(b) Hot do I get the timestamp of the beginning of a day? 00:00:00h on 11/24/2006 for example?
I always get this error: Can't call method "mtime" on an undefined value at........
from this code: stat($file)->mtime; Why is that???

Or is there a better solution than my idea, that I might understand?

Thanks a lot,

Greetings Sascha

Last edited by Cornholio; 11-24-2006 at 06:21 AM.
 
Old 11-24-2006, 09:00 AM   #2
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
If you're just interested in the day, maybe you could get the timestamp with stat, and then use the POSIX module strftime function to format it to just the date string (not including time), and compare that?
 
Old 11-26-2006, 11:00 PM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
I think we'd need to see more of the actual code to solve a prob like 'undefined value'...
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
I have no sound today...yesterday i did. TallAmericano Linux - Newbie 6 08-06-2006 09:12 AM
DOOM3 worked yesterday, doesn't today NetRAVEN5000 Linux - Games 9 10-22-2005 06:25 PM
Yesterday I had audio, today I don't. mimsmall Linspire/Freespire 1 08-09-2004 04:43 PM
windows yesterday linux today eggeman Linux - Software 10 10-06-2003 10:21 PM
Today-Yesterday Axo LQ Suggestions & Feedback 6 07-15-2003 09:39 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:13 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration