#!/usr/bin/perl -w use strict; #use Getopt::Long; use IO::File; # Reads a file and returns it as a string # `fileName' the name of the file to be read # returns the content of the file as a list of lines in list context # or as a string in scalar context sub getFile($) { my ($fileName) = @_; print("getFile: $fileName\n"); local *IN; open(IN, "<$fileName") or die("Error open($fileName): $!"); if (wantarray) { my @line = ; return map { my $value = $_; chomp($value); $value; } @line; } else { my $fileValue = join("",); chomp($fileValue); return $fileValue; } } sub getLocalConfig($) { my ($file) = @_; my @localCfg = getFile("$file"); # reorganize the list so that all space delimited items are # individual elements my $flat = join(" ", @localCfg); # remove any extraneous whitespace $flat =~ s/\t\r\f\n//g; @localCfg = split(/ /, $flat); return @localCfg; } sub readLocalConfig($) { my ($cfgName) = @_; print("Reading local configuration\n"); # read a local config file .build-cfg if (-e "$cfgName") { return getLocalConfig("$cfgName"); } else { print("No local config file\n"); } } sub main() { @ARGV = readLocalConfig("build-cfg"); print(@ARGV); print("\n"); # hand this off to GetOptions::Long to parse } main();