473,503 Members | 2,082 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How does a perl script get the last-modified date of a file?

The PERL statement I use to open a text file looks like this:
open(HANDLE, $filename);
Now how can I get the "last modified" date of that file?
I need a solution that works the same under Windows or Unix.

- Rich

Jul 19 '05 #1
2 19004
Rich Pasco wrote:
The PERL statement I use to open a text file looks like this:
open(HANDLE, $filename);
Now how can I get the "last modified" date of that file?
I need a solution that works the same under Windows or Unix.


my $date = localtime( (stat HANDLE)[9] );

http://www.perldoc.com/perl5.8.0/pod/func/stat.html

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

Jul 19 '05 #2
Gunnar Hjalmarsson wrote:
Rich Pasco wrote:
The PERL statement I use to open a text file looks like this:
open(HANDLE, $filename);
Now how can I get the "last modified" date of that file?
I need a solution that works the same under Windows or Unix.


my $date = localtime( (stat HANDLE)[9] );

http://www.perldoc.com/perl5.8.0/pod/func/stat.html


Perfect, thanks!

- Rich

Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
5058
by: Sandman | last post by:
The subject says it all. I am doing a: I have a perl script in which I am using a ReadParse routine that parses the $ENV{'QUERY_STRING'} or $ENV{'CONTENT_LENGTH'} which are two variables passed...
9
4797
by: I Report, You Decide | last post by:
A hosting service lungcapage has banned yabb, because it takes too much CPU/memory, but phpBB is fine. Is that perl/php or the script itself? why perl sucks more resource of a server than php? i...
18
2413
by: Mike | last post by:
I'm fairly new to PHP, but a long time Perl coder. This is probably answered somewhere, but I haven't been able to find it. The "strength" behind Perl is in its modules; are there modules...
4
8119
by: Mark Wilson CPU | last post by:
This must be easy, but I'm missing something... I want to execute a Perl script, and capture ALL its output into a PHP variable. Here are my 2 files: -------------------------------------...
3
6528
by: dpackwood | last post by:
Hello, I have two different scripts that do pretty much the same thing. The main perl script is on Windows. It runs and in the middle of it, it then calls out another perl script that then...
5
2514
by: Karyn Williams | last post by:
I am new to Pyton. I am trying to modify and understand a script someone else wrote. I am trying to make sense of the following code snippet. I know line 7 would be best coded with regex. I first...
2
1800
by: gwigg | last post by:
Hi, am am having a problem with extracting all the data I want using a perl script the data being in a mysql database. The script works fine until row 59101 is reached in the 1st table, anyone aware...
3
1548
by: Zudnic | last post by:
Hi, long time listener, first time caller so to speak. Thanks to everyone who has answered other questions that I've found and used. I'm self-taught in Perl and have been hacking at it for more...
3
2507
by: Perl Beginner | last post by:
A few days ago, i was trying to make my perl script an executable (with no success). but that's not the direction of my question (at least not right now). Once i stopped trying to make the...
3
3885
by: happyse27 | last post by:
Hi All, I am creating the perl script using html form(with embedded javascript inside). When using this html form with javascript alone, it works where the form validation will pop up...
0
7205
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7093
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7287
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7011
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7468
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5596
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5023
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3170
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
401
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.