> Hi Dan,

Howdy!

> 
> Yep, that's the one:
> >Or do you want one script to list the mailers in order or
> >date and then when clicked display the contents?
> 
> I've asked about renaming, but it's out of my control. You're 
> right about the confusion... that's why I couldn't figure out 

You could sort them based on the creation date. That would work if they are 
created on the day that you want them to be known as.

Here's how I'd do that ::

#!/usr/bin/perl -w

use strict;

use File::Slurp;
use CGI qw/:standard/;

my $file = param('file');
my $actn = param('action');

my $this_script = url(-relative=>1); 
# this is a handy little trick I use so I don't have to worry about 
# links or forms to self getting messed up if I change the script's name.
# just fyi :)

        print header();

        if($actn eq 'show') { print read_file($file);exit; }

        my %fileinfo;

        my @files = read_dir(".");

        foreach my $file(@files) {
                my @tmp = stat($file);
                $fileinfo{$file} = $tmp[9];
        }

# $tmp[9] is the number of seconds since "The Epoch" that the file was last *modified* 
, not *created*.
# So you want to sort by values of $fileinfo highest to lowest, IE newest to oldest.

        foreach my $key (sort { $fileinfo{$b} <=> $fileinfo{$a} } keys %fileinfo) {
                my $t = localtime($fileinfo{$key});
                print "\&\#149\; <a href=\"$this_script?action=show&file=$key\"> $t :: 
$key </a><P> \n";             
        }

So you could use stat() and localtime() a bit more in depth to make it fancier.
Not sure exactly if/how you can find the actual creation time.

So it would be better to rename with a timestamp because that won't change but if you 
go and edit
a file that was created a year ago then it will show up as the newest one since was 
modified last.
Although even in that case it would still have the name to clarify when it is from.

Hope that helps!

DMuey 

> how to sort them correctly. So, I thought that the "date 
> created" field would be the best place to sort. (But I 
> wouldn't know where to begin about that!)
> 
> Thanks for responding so quickly! (I hope you don't mind, but 
> I added your name to the script that I'm currently using.)

Cool.

> 
> --Deborah
> 

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to