I'm disturbed because I don't understand how the subroutine used as its first parameter gets $_
The nice thing about open source is that you can take a look at the code, if you want to know how something is being done. In many cases, an educated guess what keywords to grep for is all that's needed to jump to the right place. In this case, when you search for $wanted_callback, you find something like this (there are several similar snippets):
$dir= $p_dir; # $File::Find::dir
$name= $dir_name; # $File::Find::name
$_= ($no_chdir ? $dir_name : $dir_rel ); # $_
# prune may happen here
$prune= 0;
{ $wanted_callback->() }; # protect against wild "next"
As you can see, the callback routine is called without argument, but $_ (and other global variables) are populated before the call.
-
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.
|