Solved

Time-Stamp & Filename Hash

Posted on 1998-11-24
2
687 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
[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
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
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

729 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