You're use'ing Getopt but you aren't actually using it.

The following code has absolutely no place in your program if you're using Getopt::Long:

$beginAddrHex = $ARGV[0]; $endAddrHex = $ARGV[1]; $numberOfSims = $ARGV[2];

You should be letting GetOptions do the work of getting the options. That's its reason for being. Your line should probably look more like this.:

GetOptions( \%options, qw[ help+ delete+ err_dup=s{3} ] );

This also means your %options hash should look something like this (if you believe in pre-populating it).:

my %options = ( 'help' => 0, 'delete' => 0, 'err_dups' => [], );

And then your if branch for err_dup would be more like this.:

if ( $options{ 'err_dup' } ){ print "err_dup is called\n"; my ( $beginAddrHex, $endAddrHex, $numberOfSims ) = @{ $options +{ 'err_dup' } }; # or just pass the option straight to the sub you're + about to call } else { print "err_dup NOT called\n"; }

Why you'd use GetOptions to make all the options numeric flags then try to pick apart @ARGV (with the wrong indexes, BTW) is beyond me. Just follow the docs and use string options and repetition specifiers (called a "repeat specifier" in the docs). You can also specify an array type if you're not sure how many you'll need.

Oh, and since you're using hex you could enforce option type checking if you're willing to enter your hex values as 0xf68 and 0xF100 and such.:

GetOptions( \%options, qw[ help+ delete+ err_dup=o{3} ] );

In reply to Re: PERL - newbie: first time working with GetOptions error given when running script by mr_mischief
in thread PERL - newbie: first time working with GetOptions error given when running script by lshokri02

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.