On Thu, Sep 9, 2010 at 10:25, Jatin <daveyja...@gmail.com> wrote:
>
>> Hi Jatin,
>>
>> A callback is a reference to a subroutine.
>
> [Jatin] if a callback is a reference to a subroutine then it can be stored
> in scalar variable to call that subroutine. Am i correct in my understanding
> ?

Yes, all types of references can be stored in scalars.

snip
> [Jatin] So in actual terms the File::Find's find() method in turn invokes
> our callback subroutine but i am confused at one point , what is
> "File::Find::name" ,
>
> how does it return the complete path of the filename ?
snip

$File::Find::name is a package variable from File::Find.
File::Find::find (i.e. the find function) sets that value each time
before it calls the callback.

snip
> If the File::Find's find method calls our subroutine , and we do not have
> any lexical variable called as name then how come the execution of our
> callback subroutine returns the complete path of the file name ?
snip

The callback is printing the value of $File::Find::name (which, again,
is set by the File::Find::find function before the callback is
called).


File::Find's interface is through its package variables.  It is a very
bad design and is much regretted, but there is nothing to do about it
now.

-- 
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to