Hello Monks

I have being using Perl for a while but only recently had any need to start looking at OOP. I notice a couple of odd things that I hope someone could clear up?

What is the reason for the first argument that is passed to the routine in a class being the class name? Is this useful in certain ways?

Secondly, I noticed that if I export my functions, from the class, and then, in my calling script call it by its name (e.g &function("data") ) then the first argument isn't the class name. However, if I call it directly e.g MyDir::Class->function("data"), from the same script, then the first argument is the class name.

Is there good reasons why this is the case, or am I doing something really silly!?


In reply to Basic Class question by packetstormer

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.