/[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.2 - (hide annotations)
Sat Feb 1 02:52:32 2003 UTC (21 years, 5 months ago) by joko
Branch: MAIN
Changes since 1.1: +7 -6 lines
File MIME type: text/plain
+ minor update

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

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