I don't understand why you are asking questions 1 to 4. Surely it's easier to try out whether it's possible than typing in the question?

As for 5), the answer is, "it's not really a sensible question". Global variables have to do with scope - a variable is global if it can be accessed from the outer scope. Lexical (my) can, if declared appropriately. Package variables always can (obviously), but they don't need to be declared - from a language point of view, they always exist. "use vars" is just a way of telling Perl "in this scope, I'm going to use these package variables, and I'm not going to refer to them by their full name" (use vars will have some effects in perl - but that's implementation, not language).

As for 6), there's no difference. But there is a difference between my($x, $y); and my $x, $y;. The former is equivalent to my $x; my $y;, the latter to my $x; $y;.

I do not understand question 7). Where is my $c?

8) you can just try out for yourself.


In reply to Re: Understanding difference between my and local variables. by JavaFan
in thread Understanding difference between my and local variables. 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.