11
11
use warnings;
12
12
13
13
use File::Find;
14
+ use Tie::File;
14
15
15
16
my $pgdg =' PostgreSQL Global Development Group' ;
16
17
my $cc =' Copyright \(c\)' ;
22
23
find({wanted => \&wanted,no_chdir => 1},' .' );
23
24
24
25
sub wanted {
25
- my $filename = $File::Find::name ;
26
+ return if ! -f $File::Find::name || -l $File::Find::name ;
26
27
27
- # only regular files
28
- return if ! -f $filename ;
28
+ my @lines ;
29
+ tie @lines , " Tie::File " , $File::Find::name ;
29
30
30
- open (my $FILE ,' <' ,$filename )or die " Cannot open$filename " ;
31
-
32
- foreach my $line (<$FILE >) {
31
+ foreach my $line (@lines ) {
33
32
# We only care about lines with a copyright notice.
34
33
next unless $line =~m /$cc .*$pgdg / ;
35
34
# We stop when we've done one substitution. This is both for
@@ -39,7 +38,7 @@ sub wanted {
39
38
last if $line =~s / ($cc\d {4})(, $pgdg)/ $1 -$year$2 / ;
40
39
last if $line =~s / ($cc\d {4})-\d {4}(, $pgdg)/ $1 -$year$2 / ;
41
40
}
42
- close ( $FILE ) or die " Cannot close $filename " ;
41
+ untie @lines ;
43
42
}
44
43
45
44
print " Manually update doc/src/sgml/legal.sgml and src/interfaces/libpq/libpq.rc.in too\n " ;