ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/msatfinder/msatlister
Revision: 1.1.1.1 (vendor branch)
Committed: Mon Mar 7 15:34:45 2005 UTC (11 years, 5 months ago) by knirirr
Branch: MAIN
CVS Tags: HEAD, HEAD
Changes since 1.1: +0 -0 lines
Log Message:
First import

Line File contents
1 #!/usr/bin/perl
2
3 #################################################################
4 # NAME: msatlister.pl #
5 # FUNCTION: list or delete the genomes in a directory, getting #
6 # around the shell's globbing problem. #
7 #################################################################
8
9 use strict;
10 use warnings;
11 use Getopt::Std;
12
13 my %opts;
14
15 my $usage = <<USAGE;
16
17 Usage:
18 -g suffix to glob ("." not needed)
19 -o output file name (default is "files.list")
20 -d delete the files with the suffix given by -g
21 -h list these options
22
23 e.g. msatlister -g gbk -o bacteria.list
24 msatlister -g gbk -d
25
26 USAGE
27
28 # display a help message
29 if (@ARGV == 0) { print "$usage"; exit; }
30 getopts('hdo:g:',\%opts);
31 if ($opts{h}) { print "$usage"; exit; }
32
33 # glob in the list of files
34 my @files;
35 if ($opts{g})
36 {
37 @files = glob "*$opts{g}";
38 }
39
40 # delete the files instead
41 if ($opts{d})
42 {
43 unlink glob "*$opts{g}";
44 print "Files with suffix \"$opts{g}\" deleted.\n";
45 exit;
46 }
47 # write list to an output file
48 else
49 {
50 my $outputfile;
51 if ($opts{o})
52 {
53 $outputfile = $opts{o};
54 }
55 else
56 {
57 $outputfile = "file.list";
58 }
59 open (OUT, ">$outputfile") or die "$!";
60 foreach (@files)
61 {
62 print OUT "$_\n";
63 }
64 close OUT;
65 }
66
67 # finished
68 print "Done!\n";