package X::Y::Z;
sub xyz { ... }
sub abc {
X::Y::Z::xyz();
# I have just called xyz() from this current package
# by using the above expression, except from making sure I don't a
+ccidentally call another xyz(),
# my intent is to say:
# "reader: don't go looking for xyz() elsewhere, it is declared
+in this same package"
# but the above is too long and some reader may forget
# what package there editor is currently showing or confuse it wit
+h similarly named: X::Y::Z1 etc.
# I would prefer a shorter but equivalent way of calling xyz() of
+current package
# similar to ::xyz() for main - short and to the point: this sub i
+s implemented IN THIS package
}
I would like to show to the reader of my programs where this variable or that function is declared/defined in. Especially when that reader is me later on. I would hate to save stack and go to cpan or my local disk to search for this function's implementation. Just to notice later that it is further below in same file in my editor.
So, I usually use the fully-qualified name for subs that I am using, like in the above code X::Y::Z::xyz();. But that's a bit awkward for me and the reader especially for long package names. So, I thought perhaps there is another way in Perl to write xyz() to mean in this package, in order to show to the reader (and perl) that this function's source code is just below or above this line and should not open another window to search for it.
For example, when in main package, we refer to subs within this package either as xyz() or main::xyz() (which is what I want to avoid: too short/too long). But then is the cute little ::xyz(). The reader gets the message immediately, that xyz() is further below or above current line. Any ideas for the other packages?
thanks, bliako
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|