in reply to how to assign output of Find() into a variable $

Create an empty array, then change the contents of the “wanted” subroutine (the anonymous sub) to push the required files onto the array rather than printing them:

#! perl use strict; use warnings; use File::Find; my @filtered = (...); my @files; find(sub { push @files, $File::Find::name if /\.lef$/ } , @filtered); # access @files as needed

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

Replies are listed 'Best First'.
Re^2: how to assign output of find() into a variable
by teddy6507 (Initiate) on May 18, 2016 at 07:57 UTC
    thanks Athanasius! you save my day

    finally , I am able to assign after so many tries :( . i tried push earlier but it didn't work due to various syntax errors.

    find ( sub { print $File::Find::name , "\n" if /\.lef$/ } , @filter +ed); print join("\n" , @files, "\n");