On Mon, Nov 24, 2008 at 14:41, Harry Putnam <[EMAIL PROTECTED]> wrote: snip > It looks like what you've done is pass an entire sub function into > another sub function. So there ends up being 3 sub function in all. > > I see it works but I'm still a little confused about `wanted()'. > > Is it not considered a sub function? I'm not clear on `named' as > against simple `sub {...}' snip
sub foo { #blah } is a named subroutine. It is created at compile time. my $coderef = sub { #blah }; is an anonymous subroutine. It is created at runtime. The File::Find::find function wants a coderef, you can get one by writing a named function and passing a reference to it: sub wanted { #blah }; File::Find::find(\&wanted, @dirs); but often you don't really need a named function(which is accessible from everywhere in the program), you just want File::Find::find to do something specific to the code around it. In these cases an anonymous subroutine is ideal. They also have the benefit of being able to see the variables that are currently in scope. File::Find::find(sub { #blah }, @dirs); You may want to read http://perldoc.perl.org/perlsub.html for more information. -- Chas. Owens wonkden.net The most important skill a programmer can have is the ability to read. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/