in reply to Re: Re: join this
in thread splitting command-line arguments

Do you know the format of the command lines that you will be getting from the file? If so, you can still use Getopt::Long or Getopt::Std if you localize @ARGV. Here's a bit of code I've used in the past to accomplish a similar task. This code uses Getopt::Std and the parse_cmd function returns a hash rather than an array so it doesn't meet IraTarball's exact specs, but it should be a nudge in the right direction. Here goes --

use strict; use Getopt::Std; use Data::Dumper; sub parse_cmd{ my $cmdline = shift; local @ARGV; @ARGV = split('\s+',$cmdline); shift @ARGV; my %options; getopts("x:y:z:abc", \%options); return %options; } my %opts = parse_cmd("someprg -x foo -y bar -z baz -ab"); print Dumper(\%opts);
Output from perl test.pl -f commandline.txt:

$VAR1 = { 'x' => 'foo', 'y' => 'bar', 'a' => 1, 'z' => 'baz', 'b' => 1 };

The logic would be the same for Getopt::Long or any of the other command line parsing options on cpan. Of course if you don't know what possible command line arguments are going to be passed, then you may want either look at something like Parse::RecDecent or look at the code of Getopt::Long.

----
Coyote