/[cvs]/nfo/perl/scripts/archiver/bin/finder.pl
ViewVC logotype

Annotation of /nfo/perl/scripts/archiver/bin/finder.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations)
Sat Feb 1 01:38:35 2003 UTC (21 years, 5 months ago) by joko
Branch: MAIN
File MIME type: text/plain
+ initial commit - partly refactored from replace_cvs.pl

1 joko 1.1 #!/usr/bin/perl
2    
3     ## ------------------------------------------------------------------------
4     ## $Id: Simple.pm,v 1.4 2002/12/28 07:55:26 joko Exp $
5     ## ------------------------------------------------------------------------
6     ## $Log: Simple.pm,v $
7     ## ------------------------------------------------------------------------
8    
9    
10     =pod
11    
12     finder.pl - find things (files) and print their names on STDOUT
13    
14     - finder.pl
15     finds all files/directories in current path
16    
17     - finder.pl .
18     finds all files/directories in current path (again)
19    
20     - finder.pl --regex=test
21     finds all files/directories matching 'regex' in current path
22    
23     - finder.pl --regex=/CVS/Root$ /tmp/cvsroot
24     finds all files/directories matching 'regex' in path '/tmp/cvsroot' and below (recursively)
25    
26     =cut
27    
28    
29     use strict;
30     use warnings;
31    
32     BEGIN {
33     use FindBin qw($Bin);
34     #require "$Bin/use_libs.pl";
35     }
36    
37     use lib qw( ../../../libs ../libs ../etc );
38     #use org::netfrag::preambel;
39    
40     use Data::Dumper;
41     use File::Find;
42     use Getopt::Easy;
43    
44     # ----------------------------------------
45     # main
46     # ----------------------------------------
47     package main;
48    
49    
50     my $settings;
51    
52     sub wanted {
53     my $pattern = $settings->{options}->{regex};
54     #print "pattern: $pattern", "\n";
55     if ($File::Find::name =~ m/$pattern/) {
56     print $File::Find::name, "\n";
57     #replaceInFile($File::Find::name);
58     #exit;
59     }
60     }
61    
62     sub main {
63    
64     my $defaults = {
65     options => {
66     'recursive' => 0,
67     'regex' => '.*',
68     },
69     args => [qw( . )],
70     };
71    
72     my $optReader = Getopt::Easy->new();
73     $optReader->merge_defaults($defaults);
74     $optReader->merge_cli_arguments();
75     $settings = $optReader->getOptions();
76    
77     #print Dumper($settings); exit;
78    
79     #find(\&wanted, $settings->{args}->[0]);
80     my $where = $settings->{args}->[0];
81     find(\&wanted, $where);
82    
83     }
84    
85     main();
86    
87     1;
88     __END__

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed