It's a question of intent. If your goal is to ask an object to take the "grep" action on a thingie and give you the result, you use a method call. If your goal is take a specific (global) action "grep" against a thingie and an object which you assume is an array (where the grep action indicates that it will do what it can to make it's argument an array and if it can't it will fail) then you use the function syntax.
Forget "grep" for a moment and imagine i'm providing you a a library that implements a "dothat" function. If you want to execute my "dothat" function against objectA and objectB, you call the funtion. If objectA says that coincidently it has a "dothat" method and you want to ask objectA to "dothat" to objectB you call the method.
-
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.
|