#!/usr/bin/env perl # Make list of files containing source code. The source list contains all # .F90, .f90, .F, and .c files in a specified list of directories. The # directories are specified one per line in a file called Filepath which # this script tries to open in the current directory. The current # directory is prepended to the specified list of directories. If Filepath # doesn't exist then only the source files in the current directory are # listed. # The list of source files is written to the file Srcfiles. # Check usage: @ARGV == 0 or usage(); open(SRC,"> Srcfiles") or die "Can't open Srcfiles\n"; if ( open(FILEPATH,"< Filepath") ) { @paths = ; close( FILEPATH ); } else { @paths = (); } chomp @paths; unshift(@paths, '.'); foreach $dir (@paths) { # (could check that directories exist here) $dir =~ s!/?\s*$!!; # remove / and any whitespace at end of directory name ($dir) = glob $dir; # Expand tildes in path names. } # Loop through the directories and add each filename as a hash key. This # automatically eliminates redunancies. %src = (); foreach $dir (@paths) { @filenames = (glob("$dir/*.[Fc]"), glob("$dir/*.[Ff]90")); foreach $filename (@filenames) { $filename =~ s!.*/!!; # remove part before last slash $src{$filename} = ""; } } foreach $file ( sort keys %src ) { print SRC "$file\n"; } close( SRC ); #-------------------------------------------------------------------------------------- sub usage { ($ProgName = $0) =~ s!.*/!!; # name of program die <