Fix build failure for muse-ikiwiki.
[muse-el.git] / contrib / blosxom / getstamps.pl
blobdeee493867cf06a62d052fb2a9399d07799d6e30
1 #!/usr/bin/perl -w --
4 # $Id: getstamps.pl,v 1.3 2007-08-19 13:46:54 welle Exp $
7 # Author: Michael Welle
9 # This file is available under the terms of the GNU General Public
10 # License, Version 2.
12 # Modified by Michael Olson to add Author note. license text, and to
13 # fix a use of "muse" rather than $muse_file_extension.
15 #my $tsfile = "/tmp/blog/timestamps";
16 my $tsfile = "-";
17 my $muse_file_extension = "muse";
22 sub process_file {
23 my ($file) = @_;
26 open( F, "<$file" );
28 while ( <F> ) {
30 if ( /^#date\s+(.+)$/ ) {
32 close ( F );
33 my $d = $1;
35 $file =~ s/\.${muse_file_extension}$/\.txt/;
36 $file =~ s/^\.\///;
38 if ( $d =~ /(\d\d\d\d)-(\d\d)-(\d\d)-(\d\d)-(\d\d)/ ) {
40 printf TS "${file}=>$2/$3/$1 $4:$5\n";
41 return;
43 } # if
45 } # if
47 } # while
49 close( F );
51 } # process_file
58 sub traverse_directory {
59 my ($directory) = @_;
60 local *DIR;
61 my @files = ();
62 my $pfad = "";
65 opendir( DIR, $directory );
66 @files = readdir( DIR );
67 closedir( DIR );
70 foreach my $file ( @files ) {
72 next if ( !( $file =~ /^.*\.${muse_file_extension}$/ )
73 || ($file eq '.') || ($file eq '..'));
76 $path = "$directory/$file";
78 if( -d $path ) {
80 traverse_directory( $path );
82 } else {
84 process_file( $path );
86 } #if
88 } #foreach
90 } # traverse_directory
94 # Here we go...
97 open( TS, ">${tsfile}" );
99 if ( @ARGV == 0 ) {
101 traverse_directory( "." );
103 } else {
105 traverse_directory( $ARGV[0] );
107 } #if
109 close( TS );
111 exit 0;