in reply to Re: Search and replace copyright to .java scripts
in thread Search and replace copyright to .java scripts
my $root = 'f:/'; my %hash = (); # # main # { my @files = getFileList(); # find files within given vobs my $n = @files ; print STDERR "Searching $n files\n" ; my $n = 0 ; foreach my $f (@files) # open found files { $n++ ; print STDERR "$n\r" ; unless (open( SRC, $f )) { print STDERR "Unable to open $f: $!\n" ; next ; } while (<SRC>) { last if (/^\s*package/); #next unless (/\$Workfile/m); # get filename next unless (/copyright.*application/i); # get copyright chomp ; # remove newline s/^\s*\*//; # remove comments s/\s+/ /; # multiple whitespace into single whitespac +e s/^\s+// ; # remove any leading whitespace s/\s+$// ; # remove any trailing whitespace $hash{ $_ }++; last ; } close (SRC); } foreach my $k (sort keys %hash) { my $v = $hash{ $k }; #print STDERR "$v: $k\n" ; print STDERR "$_\n" ; } } my @theFiles = (); sub getFileList() { my @files = (); foreach my $k ("dir1", "dir2") { @theFiles = (); find( \&wanted, "$view/$k/src" ); push @files, @theFiles ; } return @files ; } sub wanted { return unless (-f $_ ); return unless ($_ =~ /\.java$/); push @theFiles, $File::Find::name ; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Search and replace copyright to .java scripts
by jacques (Priest) on Feb 03, 2003 at 20:43 UTC |