ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/Utilities/SCRAMUtils.pm
Revision: 1.5
Committed: Tue Apr 13 16:13:38 1999 UTC (26 years, 1 month ago) by williamc
Content type: text/plain
Branch: MAIN
CVS Tags: V0_10_19, V0_10_18, V0_10_17, V0_10_16, V0_10_15, V0_10_14, V0_10_13, V0_10_12, V0_10_11, V0_10_10, V0_10_9, V0_10_8, V0_10_7, V0_10_6, V0_10_5, V0_10_4, V0_10_3, V0_10_2, V0_10_1, V0_10_0, V0_10_0beta, V0_9_42, V0_9_41, V0_9_40, V0_9_39, V0_9_38, V0_9_37, V0_9_36, V0_9_35, V0_9_34, V0_9_33, V0_9_32, V0_9_31, V0_9_30, V0_9_29, V0_9_28, V0_9_27, V0_9_26, V0_9_25, V0_9_24, V0_9_23, V0_9_22, V0_9_21, V0_9_20, V0_9_19, V0_9_18, V0_9_17, V0_9_16, V0_9_15, V0_9_14, V0_9_13, V0_9_12, V0_9_11, V0_9_10, V0_9_9, V0_9_8, V0_9_7, V0_9_6, V0_9_5, V0_9_4, V0_9_3, V0_9_2, V0_9_1, V0_9
Branch point for: V0_9branch
Changes since 1.4: +2 -2 lines
Log Message:
Lost an s in thisfile

File Contents

# User Rev Content
1 williamc 1.1 #
2     # Utility Routines for the SCRAM tools
3     #
4    
5     package SCRAMUtils;
6 williamc 1.2 require 5.001;
7 williamc 1.1 require Exporter;
8     @ISA = qw(Exporter);
9     @EXPORT = qw(checkfile updatelookup);
10     use Carp;
11    
12 williamc 1.3 sub checkfile {
13 williamc 1.1 my $filename=shift;
14     my $thisfile="";
15 williamc 1.5 $thisfile=$ENV{LOCALTOP}."/".$filename;
16 williamc 1.1 return $thisfile, if ( -e $thisfile );
17 williamc 1.5 $thisfile=$ENV{RELEASETOP}."/".$filename;
18 williamc 1.1 return $thisfile, if ( -e $thisfile );
19     return "";
20     }
21    
22     #
23     # Replace or add an entry in a hashing file
24     #
25     sub updatelookup {
26     my $filename=shift;
27     my $key=shift;
28     my $rest=shift;
29     my $update=0;
30     use File::Copy;
31    
32     open ( SCRAMWORK, ">$filename.wk" ) or
33     croak "Unable to open $filename.wk ".$!."\n";
34     open ( SCRAMUPDATEFILE, $filename );
35 williamc 1.4 print "Searching for ".$key."\n";
36 williamc 1.1 while ( <SCRAMUPDATEFILE> ) {
37     if ( $_=~/^\Q$key\E/o ) {
38     $update=1;
39     print SCRAMWORK $key.$rest."\n";
40     }
41 williamc 1.4 else {
42     print SCRAMWORK $_;
43     }
44 williamc 1.1 }
45     close SCRAMUPDATEFILE;
46     if ( $update==0 ) {
47     print SCRAMWORK $key.$rest."\n";
48     }
49     close SCRAMWORK;
50     copy "$filename.wk", $filename or croak "Unable to update file "
51     ."$filename $!\n";
52    
53     }