Solved

NEED HELP WITH GETTING FILE DATE

Posted on 2006-11-22
3
288 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
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…
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…
Six Sigma Control Plans

707 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