Much of this can be understood by checking the relevant documentation.

1) While you could declare these variables to be package variables (using our, or by using their full names, you don't really gain any benefit over declaring them as lexical variables with my.

IMHO, the main reason for using my is to help develop good habits. When making a module, you might want to declare variables that are only available inside the module. You would use my for this. The only reason to use our would be if you wanted the variables to be accessible outside the module. Using my by default gets you in the habit of reducing the coupling between different parts of you code, unless you specifically choose otherwise.

2) The dirname in this case is a function call (see File::Basename). This is not to be confused with $dirname which is a scalar variable. dirname has no more in common with $dirname than @dirname does. Using different names would have made this example a bit clearer.

3) Yes.

4) See the documentation for s/// (in Regexp Quote Like Operators) where you will find that the substitution operation (and the match operator m// both support alternate delimiters. In this case, the delimiter is #.

G. Wade

In reply to Re: Pls explain this syntax by gwadej
in thread Pls explain this syntax by manish.rathi

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.