title: How can I set default values using Getopt::Std?
body: <p>I am trying to collect the values from command line using <a href="http://perldoc.perl.org/Getopt/Std.html" rel="noreferrer">Getopt::Std</a> in my Perl script.</p>
  
  <pre><code>use Getopt::Std;
  $Getopt::Std::STANDARD_HELP_VERSION = 1;
  getopts('i:o:p:');
  my $inputfile = our $opt_i;
  my $outputfile = our $opt_o;
  my $parameter_value = our $opt_p;
  </code></pre>
  
  <p>Here the first two variables ($inputfile,$outputfile) are mandatory but the last variable ($parameter_value) is optional and can be ignored. </p>
  
  <p>I am trying to set some value by default to the last variable ($parameter_value) when the <code>-p</code> flag is ignored at the command line.</p>
  
  <p>I tried using this: </p>
  
  <pre><code>my $parameter_value = our $opt_p || "20";
  </code></pre>
  
  <p>Here its passes the correct value when -p flag is ignored at command line. But the problem is when I am providing some value from the command line (for instance -p 58), the same value 20 is passed to the program instead of 58 which I passed from command line.</p>
  
  <p>Can you please help me out by pointing the mistakes I am making here?</p>
  
  <p>Thank you.</p>