in reply to Re: Re: Creating Hashes from Switches
in thread Creating Hashes from Switches
If you know that the first two arguments you'll get are the XML file and the output file then you can do something like this:
#!/usr/bin/perl -w use strict; use Getopt::Std; use Data::Dumper; my %switches; %switches = splice(@ARGV, 0, 4); # parse the XML file and work out what other arguments # you're going to be passed. Use that info to build $fmt my $fmt = 'd:m:'; getopts($fmt, \%switches); foreach (keys %switches) { $switches{$_} = [ split /\s+/, $switches{$_} ]; } print Dumper \%switches;
It's a bit fragile tho' as it assumes there will be spaces between the first two options and their arguments.
--"The first rule of Perl club is you do not talk about
Perl club."
-- Chip Salzenberg
|
|---|