utku has asked for the wisdom of the Perl Monks concerning the following question:
I want to get following behaviour: If I don't give -f option, script must assume whole list in the directory must be taken to the @file_list. If I give only the number of -f arguments, it must overwrite the default. However, it doesn't. Getopt::Long doesn't overwrite but appends the -f args. For the case:#!/usr/bin/perl -w $dir = "some_dir"; @file_list = glob ("$dir/*"); GetOptions ( "f=s" => \@file_list, ); foreach (@file_list) { print { $_\n"; }
... it does overwrite, rather than append. Why is the behaviour for arrays different? Is there a way to switch off append behaviour for arrays? Perl version is 5.8.0. Regards!#!/usr/bin/perl -w $dir = "some_dir"; $file = "$dir/some_file"); GetOptions ( "f=s" => $file, );
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Getopt::Long, default of multiple options can not be overwritten by argument
by Corion (Patriarch) on Oct 28, 2011 at 18:08 UTC | |
by utku (Acolyte) on Oct 28, 2011 at 18:15 UTC |