in reply to Parsing command-line arguments in a sophisticated way.
Getopt::Long can parse command-line options from a string. So my proposal is to take all options as a string, split on --job, and then parse whatever was in front of it. Like this:
use strict; use warnings; use Getopt::Long qw(GetOptionsFromString); use Data::Dumper; my ($args, $job) = split /--job /, join( ' ', @ARGV ); my %opts; my $ret = GetOptionsFromString( $args, \%opts, "file=s", "dir=s" ); $opts{"job"} = $job if $job; print Dumper \%opts;
In Section
Seekers of Perl Wisdom