in reply to Arguments to anonymous subs

I stumbled across this problem while thinking of how to replace my `find ... ` commands with the find() subroutine implemented in File::Find module. According to docs, find() may accept a reference to a sub, which really benefited my code in that I didn't have to modify it much. However, I still have to pass 'custom' skip matches (for files/directories) in form of an argument in order to achieve desired results.
Just pass it as a closure variable. In fact, in your example, just referring to $skip_match will give you the right value!

-- Randal L. Schwartz, Perl hacker

Replies are listed 'Best First'.
Re: Re: Arguments to anonymous subs
by vladb (Vicar) on Dec 19, 2001 at 04:15 UTC
    Ahh, definitely! ;-). Thanks for the reminder, I should have definitely thought of closures for that matter. cheers

    "There is no system but GNU, and Linux is one of its kernels." -- Confession of Faith