package Scripts; # # implemented functions: # # * read_options .......... read options file # * read_filenames ........ read filename configuration file # require Exporter; @EXPORT = qw( read_options read_filenames ); ###################################################################### # read generation options file # call : &read_options(\%hash,$filename) # return : 1 ... file read # 0 ... file not found # %hash modified with values read from file ###################################################################### sub read_options (\%$) { my ($href,$file) = @_; local *OPTIONS; # check if file exists if ( -e $file ) { open (OPTIONS,$file); while () { next if (m/^#/); next if (m/^$/); /(.*):(.*)/; $$href{$1}=$2; } close OPTIONS; return 1; } else { return 0; } } ###################################################################### # read filename configuration file # call : &read_filenames(\%hash,$filename) # return : 1 ... file read # 0 ... file not found # %hash modified with values read from file ###################################################################### sub read_filenames (\%$) { my ($href,$file) = @_; local *CONFIG; # check if file exists if ( -e $file ) { open (CONFIG,$file); while () { next if (m/^#/); next if (m/^$/); my @a=split; $$href{$a[1]}=$a[3]; } close CONFIG; return 1; } else { return 0; } }