Scrat has asked for the wisdom of the Perl Monks concerning the following question:
Hi Monks
I have a perl script that accepts the following command line syntax in Linux:
./script.pl -file myfile.txt -file yourfile.txt -file ourfile.txt
My code looks like this:
Prints:#!/usr/bin/perl use strict; use warnings; use Getopt::Long qw (GetOptions); my (@Files); Getopt::Long::Configure("no_ignore_case", "prefix_pattern=(--|-|\/)"); GetOptions ("file=s@" => \@Files); foreach (@Files) { #Do stuff with file print "$_\n"; }
myfile.txt yourfile.txt ourfile.txt
When I try and run the following command though, it only returns the first filename (myfile.txt).
./script.pl -file *.txt
Why does this happen and how can I get my script to accept wild card characters?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Getopt Long and processing arrays from Linux shell
by Anonymous Monk on Jun 21, 2007 at 09:22 UTC | |
by Scrat (Monk) on Jun 21, 2007 at 09:34 UTC | |
by citromatik (Curate) on Jun 21, 2007 at 10:06 UTC | |
by moritz (Cardinal) on Jun 21, 2007 at 09:57 UTC | |
|
Re: Getopt Long and processing arrays from Linux shell
by Anonymous Monk on Aug 09, 2011 at 12:57 UTC |