ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/Utilities/SCRAMUtils.pm
Revision: 1.2
Committed: Mon Mar 1 11:01:36 1999 UTC (26 years, 2 months ago) by williamc
Content type: text/plain
Branch: MAIN
Changes since 1.1: +1 -1 lines
Log Message:
get rid of unessary shell invocation stuff in modules

File Contents

# Content
1 #
2 # Utility Routines for the SCRAM tools
3 #
4
5 package SCRAMUtils;
6 require 5.001;
7 require Exporter;
8 @ISA = qw(Exporter);
9 @EXPORT = qw(checkfile updatelookup);
10 use Carp;
11
12 sub checkfile ($filename) {
13 my $filename=shift;
14 my $thisfile="";
15 $thifile=$ENV{LOCALTOP}."/".$filename;
16 return $thisfile, if ( -e $thisfile );
17 $thifile=$ENV{RELEASETOP}."/".$filename;
18 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 while ( <SCRAMUPDATEFILE> ) {
36 if ( $_=~/^\Q$key\E/o ) {
37 $update=1;
38 print SCRAMWORK $key.$rest."\n";
39 }
40 print SCRAMWORK $_;
41 }
42
43 close SCRAMUPDATEFILE;
44 if ( $update==0 ) {
45 print SCRAMWORK $key.$rest."\n";
46 }
47 close SCRAMWORK;
48 copy "$filename.wk", $filename or croak "Unable to update file "
49 ."$filename $!\n";
50
51 }