Solved

NEED HELP WITH GETTING FILE DATE

Posted on 2006-11-22
3
277 Views
Last Modified: 2008-02-01
I'm trying to get the modified date of a file.  This is my test code:

<-- Start Code -->
#!/usr/bin/perl
use File::stat;
open(OUTFILE,">test.dat");
($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
       $atime,$mtime,$ctime,$blksize,$blocks)
           = stat("test.dat");
print OUTFILE $mtime;
close(OUTFILE);
<-- End Code -->

Only $dev gives me some data, which is  "ARRAY(0x815596c)".  The rest of the variables give me nothing.

What am I doing wrong?

0
Comment
Question by:limva
3 Comments
 
LVL 4

Expert Comment

by:NorCal2612
ID: 17999027
what does this give you?:

#!/usr/bin/perl
use File::stat;
open(OUTFILE,">test.dat");
($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
       $atime,$mtime,$ctime,$blksize,$blocks)
           = stat("test.dat");
print OUTFILE $dev[9];
close(OUTFILE);
0
 
LVL 48

Accepted Solution

by:
Tintin earned 50 total points
ID: 17999050
Problem is you have

use File::stat;

and then never use it.  If you just want mtime, do

#!/usr/bin/perl
use strict;
my $file='test.dat';

open OUTFILE, ">$file" or die "Can not create $file $!\n";
my $mtime = (stat($file))[9];
print OUTFILE $mtime;
close OUTFILE;
0
 

Author Comment

by:limva
ID: 17999158
I removed "use File::stat;" and it worked!

Thanks guys!
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

823 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question