Solved

NEED HELP WITH GETTING FILE DATE

Posted on 2006-11-22
3
275 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
Comment Utility
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
Comment Utility
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
Comment Utility
I removed "use File::stat;" and it worked!

Thanks guys!
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
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…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

744 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now