ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/Utilities/SCRAMUtils.pm
(Generate patch)

Comparing COMP/SCRAM/src/Utilities/SCRAMUtils.pm (file contents):
Revision 1.8 by williamc, Mon Aug 28 08:35:16 2000 UTC vs.
Revision 1.10 by sashby, Wed Feb 15 17:14:18 2006 UTC

# Line 52 | Line 52 | sub updatelookup {
52          my $rest=shift;
53          my $update=0;
54          use File::Copy;
55 <
56 <        open ( SCRAMWORK, ">$filename.wk" ) or
57 <                croak "Unable to open $filename.wk ".$!."\n";
58 <        open ( SCRAMUPDATEFILE,  $filename );
59 < #       print "Searching for ".$key."\n";
60 <        while ( <SCRAMUPDATEFILE> ) {
61 <                chomp;
62 <                if ( $_=~/^\Q$key\E/ ) {
55 >        local $_;
56 >        use FileHandle;
57 >        my $fhw=FileHandle->new();
58 >        my $fh=FileHandle->new();
59 >        open ( $fhw, ">".$filename.".wk" )  ||
60 >                die "Unable to open $filename.wk ".$!."\n";
61 >        $fh->open($filename);
62 >        #print "Searching for ".$key."\n";
63 >        while ( <$fh> ) {
64 >                if ( $_=~/^\Q$key\E/o ) {
65                          $update=1;
66 <                        print SCRAMWORK $key.$rest."\n";
66 >                        print $fhw $key.$rest."\n";
67                  }
68                  else {  
69 <                 print SCRAMWORK $_."\n";
69 >                 print $fhw $_;
70                  }
71          }
72 <        close SCRAMUPDATEFILE;
72 >        undef $fh;
73          if ( $update==0 ) {
74 <                print SCRAMWORK $key.$rest."\n";
74 >                print $fhw $key.$rest."\n";
75          }
76 <        close SCRAMWORK;
76 >        undef $fhw;
77          copy "$filename.wk", $filename or croak "Unable to update file "
78                                  ."$filename $!\n";
79 <
78 < }
79 >        }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines