Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

time the file is put inside the server

by vrempire (Sexton)
on Aug 07, 2000 at 07:02 UTC ( [id://26490]=perlquestion: print w/replies, xml ) Need Help??

vrempire has asked for the wisdom of the Perl Monks concerning the following question:

hi guys,I wanted to know ,how I can read the time the file is put inside the server and how to print the time? really appreciate your concern .

Replies are listed 'Best First'.
(Ovid) Re: time the file is put inside the server
by Ovid (Cardinal) on Aug 07, 2000 at 07:26 UTC
    Are you referring to the script needing to read its own create time? Generally, this isn't possible because create time is not stored anywhere (ctime is inode change time since the epoch -- though I've read that it really is create time on MacOS). The closest you will be able to do is use stat to pull up some file statistics for it. Check out File::stat for getting to this information easier.

    I think this should get you the ctime (which is the closest you'll get):

    my $filename = 'somescript.pl'; my $ctime = (stat $filename)[10];

    If you're trying to find the time for when you're writing a file to a server, something like this can help:

    ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localt +ime(time);
    That will pull up localtime info that you can play with to your heart's content. However, I understand that localtime is or will be deprecated.

    Cheers,
    Ovid

Re: time the file is put inside the server
by vrempire (Sexton) on Aug 07, 2000 at 07:59 UTC
    Hi Ovid,thanks for helping me, actually,I want to print out the time the file is created.as we can see,when we right click the file name and see the properties,it will tell the time the file is created,modified and accessed,and I want to print anyone of it.how I can do it? Please check my script guys. opendir (DIR,$dir) or die "Can't open folder $dir: $!\n"; @files = readdir DIR or die "Couldn't read from $dir: $!\n"; foreach $file (@files) { use Time::localtime; my $ctime = (stat $file)10; print "$file $ctime \n"; } closedir DIR; thanks for the concern
      sorry,for the program.how i gonna make it easily readable?
        Put < code > tags around the code.
         ______________________________________________
        |_____¸.·ooO--(> cRaZy is co01. <)--Ooo·.¸_____|
         ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
        

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://26490]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2024-04-25 16:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found