Hi Perlmonks, I am stuck with a very basic thing in perl code being newbie to coding.

my $usage = " Usage: $scriptname (-type<type> -OIMID <oimid> -version <version_numbe +r> -out <filename> ) -type <type> :A|B -version <version_number> :Required.Minimum Security Versio +n Number. -OEMID <oemid> : Required. -out <filename> : Required. "; my %opts; $result = GetOptions ("type=s" => \$type, "version=i" =>\$version_number, "OIMID=s" =>\$oimid, "out=s" => \$filename); if ($type eq "A"){ &Add() ; } elsif ($t eq "B"){ &Sub(); } else { die "Unhandled option.\n"; } sub StingtoNum() { if ($oimid = "Google") { return "01"; } elsif ($oimid = "DELL") { return "02"; } else { return "00"; } } sub Add() { $oim = &StingtoNum; $zero="00" $Version_Info = $oim.$zero.$version_number; } $
Now when i run this program,inspite of whatever I give the value of oimid in commandline,it takes the value of oim in Add as "01".I expect if I give oimid as dell it should give 02 for oim. What am I doing wrong? Thanks in Advance for help.


In reply to calling a subroutine from another subroutine by abcdefg

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.