sub wanted { my ($spls) = @_; ... you can use $spls here ... } sub search { ... find(sub { wanted($spls) }, $seek_path); ... }