What is meant by lexical variable ? I understand all "my" variables are lexical variables. Is it a local variable ? But most of the times I see my variables declared in the beginning of the code. If its a local variable then it shd be in some subroutine. What happens if we declare variables without "my" where its declared with "my" ? I read that package variables are different from lexical variables, are there variables declared in package ? If I declare a variable and assign it some value. Now this variable happens to be in package also, will not the variable declared is program take precedence over the one in package ?
my $iwhome = TeamSite::Config::iwgethome();
my $iwmount = TeamSite::Config::iwgetmount();
($iwcfg) = "$iwhome/bin/iwconfig";
my $dcrpath = iwpt_get_dcr_name();
$dcrpath =~ s#\.iwmnt#iwmnt#g;
my $dcr_name = iwpt_get_dcr_name("basename");
my $prefix = getLOB($dcrpath);
my $prefDir = uc($prefix);
my $templatename = getDataType($dcrpath);
my $contentname = $dcr_name;
$PackageVar = 23;
If I use PackageVar in a code with value of 23, which has a vlue of 53 in package , which value will be assigned to PackageVar ?
Now when PackageVar variable is declared in package and I want the one declared in code take precedence in execution, what shall I do ? Shall I use "my" for that ?
If the variable declatred in code takes precedence over ones in package, then why do we need "my" ? Can we just not declare variables without "my" ?
Pls exlain in simple terms
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.