On Apr 20, drieux said:
>On Saturday, April 20, 2002, at 07:21 , [EMAIL PROTECTED]
>wrote:
>[..]
>> With the
>>
>> find ( { wanted => \&process_file, follow=> 0}, $Dir);
>>
>> function my program runs through a directory-tree and the
>> process_file-function works with the found files.
>>
>> In my case I want to cut a part from the path of the file (not all).
>> At the moment I use global variables to give the process_file function
>> the information what to cut. But it's not a nice way, I think.
>
>since you can not get that to say
>
> find ( { wanted => \&process_file(....), follow=> 0}, $Dir);
>
>is there some voodoo to get those variables passed to the call
>back function some slicker way????
Since you can't take a reference to a function with arguments, i.e.:
$cref = \&foo($bar);
do the next best thing:
$cref = sub { foo($bar) };
Now when you call $cref->(), you'll end up calling foo($bar).
find({ wanted => sub { process_field(...) }, follow => 0 }, $Dir);
--
Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/
RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **
<stu> what does y/// stand for? <tenderpuss> why, yansliterate of course.
[ I'm looking for programming work. If you like my work, let me know. ]
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]