Apparently the author is not familiar with this idiom, though it's pretty common.
He does say
Sure, one could pass a reference to a hash with these key
value pairs, and then decode the hash inside the subroutine. Again, this is
asking the programmer to do what the language should intrinsically understand:
in essence, to code around the language.
I missed this the first time I read the article. I'm kind
of ambivalent about this way of thinking. I accept the
argument as valid, but on the other hand it's not a whole
lot of overhead (read: not much syntactic sugar required).
The cookbook shows a number of compact techniques for doing this.
Although when writing OO Perl, it really is a drag to have to write
my $self = shift every single time.
What I have noticed with Perl is that I figure out
very few tricks myself from first principles. Just about all
of my mastery has come from reading books and other people's
code. The only other language that I have observed this is C++.
If you haven't read the Gang of Four book, and studied how
the STL works, you'll only ever skim the surface.
-- g r i n d e r
-
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.
|