using the following build-cfg file:#!/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 = <IN>; return map { my $value = $_; chomp($value); $value; } @line; } else { my $fileValue = join("",<IN>); 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();
on 5.8.2 this prints only the last entry --setString=bye whereas using 5.6.0 all entries are recovered. the point of the file being to preset command line options to the script. Again, sorry for the lack of initial information and thanks for the reponses. bill--hello --setThis=2 --helloAgain --setString=bye
In reply to I/O difference between 5.6.0 and 5.8.0 by billp
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |