In this code, "use CGI" is not used. So how will the progrma understand the environment variables ?
Offhand, I don't see any environment variables being used. If they were, it might be done through the %ENV special variable, or through some mechanism established via the  TeamSite::Config or  OLG::tpl_utils modules.

variable is defined as ($iwcfg) , why do we need bracket around variable name, what does it do ?
This is not a variable definition, but an assignment to the variable  $iwcfg which has apparently been defined in some other part of the code (assuming that strictures have been enabled, as they always should be). If strictures have not been enabled and  $iwcfg has not been elsewhere defined, the package variable  $iwcfg would autovivify at this point. In any event, the parentheses do nothing in this statement.

There are my variables declred with brackets as well. So what does it do when there are brackets around variable name ?
The only  my (or lexical) variables I see that are defined within brackets are in statements like
    (my $hostname = `$iwcfg iwwebd host`) =~ s#\n$##;
This is a 'substitution on assignment' statement in which variable definition has been combined with assignment. The statement could equivalently be written
    my $hostname;
    ($hostname = `$iwcfg iwwebd host`) =~ s#\n$##;
Other than concision, there is no benefit or effect from combining the two statements as they have been here.

Whats the point in declaring my variables at the top level in program. Since my variables are used for localalization of the sciope, why is it at the top ?
Except for  $iwmount, the lexical variables seem to have been defined fairly close to the point at which they are used. This is good practice. The lexicals  $iwhome and  $iwmount may have been defined together at the top of the code fragment to emphasize their common origin from  TeamSite::Config module functions.
Whats the point in declaring "$dcrpath" and "my $dcrpath" at the same level ? Are they different from each other ?
In the statements
    my $dcrpath = iwpt_get_dcr_name();
    $dcrpath   =~ s#\.iwmnt#iwmnt#g;
to which this question seems to refer, the lexical  $dcrpath is defined and initialized in the first statement, and then has a substitution operation performed upon it in the second statement. These two statements do different things.

BTW,  $dcrpath also apprears in the useless (in the context of this code fragment) statement
    $dcrpath =~ m/\/([^\/]+)\/data/;
in which a match is done and a sub-string is (potentially) captured, but no result of the match is ever used.


In reply to Re: Perl program questions by AnomalousMonk
in thread Perl program questions by manishrathi

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.