You could use the lone dash trick ( -- ) to separate multiple channel options. Some more thought needs to go into how to trap bad input, however. (This code doesn't handle bad input properly.)
use Getopt::Long;
use Pod::Usage;
use YAML;
my @config;
while (@ARGV) {
print join(', ',@ARGV) . "\n";
my %opt;
shift if $ARGV[0] eq '-';
GetOptions(
\%opt,
'C|channel=i',
'F|forever',
'H|hours=i',
'M|minutes=i',
) or pod2usage(2);
push @config, \%opt;
}
print YAML::Dump(\@config);
__END__
=head Synopsis
>perl tvopt.pl -C 10 -F -- --channel 1 --hours 10 --minutes 20
-C, 10, -F, --, --channel, 1, --hours, 10, --minutes, 20
--channel, 1, --hours, 10, --minutes, 20
--- #YAML:1.0
- C: 10
F: 1
- C: 1
H: 10
M: 20
=cut
--Solo
--
You said you wanted to be around when I made a mistake; well, this could be it, sweetheart.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.