Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

NEED HELP WITH GETTING FILE DATE

Posted on 2006-11-22
3
Medium Priority
?
290 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 200 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
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

604 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