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 ?
This reference when passed around,
allows other code to invoke it.
File::Find's find() method accepts a subroutine reference as the first argument
and a path in the filesystem as the second argument. find() traverses
recursively in '/' and calls your code reference (callback()) for each
file/directory it finds.
[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 ?
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 ?
Please clarify on these points.
Thus, your subroutine is able to get each item in the
path as soon as they are encountered by File::Find's find(). If find() was not
implemented to handle callbacks, the possible way to return encountered
file/directory names will be as an array or hash of file/directory names after
it has traversed and exhausted all possible file/directory names within the
path.
Regards,
Alan Haggai Alavi.
Thanks
Jatin
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/