source: subversion/applications/utils/tileDownloader/utility_config.pm @ 30254

Last change on this file since 30254 was 12945, checked in by frederik, 11 years ago

tileDownloader, a perl script written by Jozef Vince <jozef.vince@…> for downloading tiles from OSM

File size: 956 bytes
Line 
1use strict; 
2
3#--------------------------------------------------------------------------
4# Reads a tiles@home config file, returns a hash array
5#--------------------------------------------------------------------------
6sub ReadConfig{
7  my %Config;
8  while (my $Filename = shift()){
9 
10    open(my $fp,"<$Filename") || die("Can't open \"$Filename\" ($!)\n");
11    while(my $Line = <$fp>){
12      $Line =~ s/#.*$//; # Comments
13      $Line =~ s/\s*$//; # Trailing whitespace
14     
15      if($Line =~ m{
16               ^
17                \s*
18                ([A-Za-z0-9._-]+) # Keyword: just one single word no spaces
19                \s*            # Optional whitespace
20                =              # Equals
21                \s*            # Optional whitespace
22                (.*)           # Value
23                }x){
24
25        # Store config options in a hash array
26        $Config{$1} = $2;
27        print "Found $1 ($2)\n" if(0); # debug option
28        }
29    }
30    close $fp;
31
32  }
33 
34  return %Config;
35}
36
37
381;
Note: See TracBrowser for help on using the repository browser.