Hello, I'm working with a program that uses GetOptions to process command line options.I have the following command line: dowhatever -channel 1 -forever -channel 2 -minutes 10 -hours 20 -channel 3 -forever And my code:
my ( @channel, @minutes, @hours, @forever); GetOptions( " channel:s" => \@channel, "minutes:s" => \@minutes, "hours:s" => \@hours, "forever:s" => \@forever); for ( my $i=0; $i<=$#channel; $i++) { print "Channel number $channel[$i] forever $forever[$i] minutes $m +inutes[$i] hours $hours[$i] \n"; }
For a channel there can be 2 situations : forever or minutes and hours (in the same command line).My problem is that I don't know how to store for each channel it's corresponding situation. For eg. for the upper case I shall have: Channel number 1 forever 1 minutes 0 hours 0 Channel number 2 forever 0 minutes 10 hours 20 Channel number 3 forever 1 minutes 0 hours 0 Or is it possible to do something like this? Thank you very much, bory

In reply to GetOptions problem by bory

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.