in reply to Read from a header file like C
Config Filesub getEnv { my $file = shift(@_); my $ref = shift(@_); unless (-f $file) { print "Could not find $file.\n"; exit(1); } open (FILE, "< $file"); while (<FILE>) { chomp; next if /^\s*\#/; next unless /=/; my ($key, $variable) = split(/=/,$_,2); $variable =~ s/\s+//g; $key =~ s/\s+//g; $ref->{config}->{$key} = $variable; } close FILE; }
port=100 host=some.host.com
|
|---|