title: How to use GetOptions in a Perl module
body: <p>I have a main.pl code where I call a perl module function likes this:</p>
  
  <pre><code>genspicemeas::genspicemeas({-f=&gt;"filename", -block =&gt; $block, -log =&gt; $LOG})
  #assume block are initialized in the main.pl
  </code></pre>
  
  <p># LOG is a file handle in main.pl : please specify how to handle this
     # in my GetOptions reference in the perl module</p>
  
  <p>My <code>genspicemeas.pm</code> is like below:</p>
  
  <pre><code>package genspicemeas;
  use strict;
  use Getopt::Long;
  
  sub genspicemeas {
  my($opt_file,$opt_block);
  GetOptions(
   'f'=&gt;\$opt_file,
   'block' =&gt;\$opt_block);
   print "block name is $opt_block and file name is $optfile\n";
  }
  1;
  </code></pre>
  
  <p>When I run <code>main.pl</code>, I expect it to print the block name and filename 
  from the print statement in <code>genspicemeas.pm</code>, however those are printing NULL values. It seems the variables are not getting passed to the Perl module I wrote. Please I am new to using Perl modules so please any help is appreciated.</p>