Hi I have a problem with my script. When I run it like this: FieldCompare.pl -t sur out20111_23866.sorted SUR_P1023866.sorted -o results it EXITS with the following statement: **** Specify name of the output file! ***** But I passed in -o parameter called "results" SO WHY DOES $opt_o" variable NOT contain "results" (or any other parameter I pass to that option) string ? Thanks!
#!/usr/bin/perl -w use strict; use Getopt::Long; use Getopt::Std; #ArrayS of hashes my @MainFields = (); my @ReservedINFO = (); my $output_type; my $outputFile; our($opt_h, $opt_c, $opt_t, $opt_o); getopts('hc:t:o:'); # Reading specified options and calling particular initialization func +tions sub Init { my $file1; my $file2; my $tmp; if(defined($opt_h)){ print Syntax(); exit; } if(!defined($opt_t)){ print "\n***** Specify the type of the output! *****\n"; print Syntax(); exit; } $output_type = $opt_t; $file1 = $ARGV[0]; $file2 = $ARGV[1]; if((!defined($file1)) || (!defined($file2))){ print "\n***** Specify the INPUT files! *****\n"; print Syntax(); exit; } print "\nFirst file - $file1\nSecond File - $file2\n"; if(!defined($opt_c)){ print "\nNo config file provided, defualt configuration will be us +ed!\n"; init_default_config($output_type); } else { read_config_file($output_type); } if(!defined($opt_o)){ print "\n***** Specify name of the output file! *****\n"; print Syntax(); exit; } $outputFile = $opt_o;
I mean if THE VERY SAME CODE WORKS FOR 'T' OPTION why DOES IT NOT WORK for 'O' option ?

In reply to handling scripts options by gyre007

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.