Hello all,

I'm using Getopt::Euclid to create a command line parser up to this spec:

Usage:
    dbsetup.pl <dbfile> [options]

Required arguments:
    <dbfile>
        Database file name. Existing files will not be overwritten unless the
        force parameter is specified.

Options:
    -f | --force
        Force overwrite of existing database file.

    -m <X> | --mockup=<X>
        Insert mock-up data set X into the database.

The funny behavior I get is that './dbsetup -d', which has an invalid flag, will happily assume '-d' is the filename; is there a way to make it more gnu-getopt like? Ie. -d bails out with 'invalid flag' unless one specifically runs './dbsetup -- -d'?

Even more funny is that './dbsetup -m' will not die of something like '-m should be followed by a parameter and is not AND you didnt specify a filename', but also assume '-m' is the file name! Isn't this erroneous?

Thanks, Michal


In reply to Getopt::Euclid, strange behavior & how to fix? by pht

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.