Owen wrote on 25.01.2005: >On Mon, 24 Jan 2005 14:31:53 +0100 Jan Eden <[EMAIL PROTECTED]> >wrote: > >>Hi, >> >>I create monthly log files with names like statistics_01_2005.log. >>Now I have a function which returns the logfile name for the current >>month: [snip] >>In some cases I need the name of last month's logfile. To achieve >>this, I modified the subroutine like this: >> [snip]
>I just get all the file names and sort them, last months is the >second last (or first) > >opendir(DIR,$wherever) or die "Can't open DIR $!\n"; while >(defined($file = readdir(DIR))) { next unless($file =~ /\.log/); >#just take out the .log files push (@filenames,$file); >} >closedir(DIR); > ># Now I get a sorted list for inclusion in a drop down menu > >@filenames = sort{$a cmp [EMAIL PROTECTED]; > Thanks, Owen, this is a nice solution, but would generate too much overhead when dealing with hundreds of log files. - Jan -- Common sense is what tells you that the world is flat. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>