Solved

Time-Stamp & Filename Hash

Posted on 1998-11-24
2
648 Views
Last Modified: 2008-02-20
Hi,

Want to create an associative array of filename and timestamp from a listing of a directory on a unix box.

Any pointers?

Thanks,

Andreas
0
Comment
Question by:context
2 Comments
 
LVL 5

Accepted Solution

by:
b2pi earned 100 total points
ID: 1206555
perldoc File::Listing starts with ....

NAME
    parse_dir - parse directory listing

SYNOPSIS
     use File::Listing;
     for (parse_dir(`ls -l`)) {
         ($name, $type, $size, $mtime, $mode) = @$_;
         next if $type ne 'f'; # plain file
         #...
     }

     # directory listing can also be read from a file
     open(LISTING, "zcat ls-lR.gz|");
     $dir = parse_dir(\*LISTING, '+0000');

DESCRIPTION
    The parse_dir() routine can be used to parse directory listings.
    Currently it only understand Unix `'ls -l'' and `'ls -lR''



So,

use File::Listing;

for (parse_dir(`ls -l`)) {
    ($name, $type, $size, $mtime, $mode) = @$_;
    next if $type ne 'f'; # plain file
    $Files{$name} = $mtime;
}


0
 
LVL 84

Expert Comment

by:ozo
ID: 1206556
opendir(DIR,'.');
%Files=map{$_,(stat $_)[9]}readdir(DIR);
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

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 …
A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
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…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

746 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

12 Experts available now in Live!

Get 1:1 Help Now