in reply to Searching a directory tree

I think you're slightly misusing find2perl. The idea behind find2perl is that you pass it a find command and it generates a Perl script which does the same thing as the orignal command. You can then run the Perl script instead of the find or find2perl.

So, my solution would be to write a find command that does what you want and then pass that command thru find2perl to generate a Perl script which you can then run any time you want.

--
<http://www.dave.org.uk>

Perl Training in the UK <http://www.iterative-software.com>

Replies are listed 'Best First'.
Re: Re: Searching a directory tree
by wylie (Novice) on Aug 10, 2001 at 15:06 UTC
    Thanks for your reply Dave.

    Unless I'm missing something obvious I think that is what I am doing already.

    My find command isfind/home/www/*/logs/weekly i.e find all subdirectories, including new ones created since the job was last run, below /home/www that contain a logs sub-directory containing the file "weekly". This is what I want to do. The job will be run weekly using cron. Find2perl writes the code to find the files correctly but also creates a blanksub wanted{} sub-routine each time the cronned script is run.

    I then want to pass the gzip and mail commands to the "wanted" sub-routine.

    Any ideas?

    Thanks in advance.

      I think you're missing the power of the Unix find coomand :) find will not only find the file that you want, but it will also carry out the correct operations on them. find2perl will then fill in the &wanted subroutine with the correct commands to mirror that behaviour. For example, your full find command would be something like this:

      find /home/www/*/logs/weekly -exec "gzip {} \| mail me@somewhere \;"

      Try passing that to the find2perl command and you'll get stuff in the &wanted subroutine.

      See the find man page for more details of cool things you can do with find.

      --
      <http://www.dave.org.uk>

      Perl Training in the UK <http://www.iterative-software.com>

        You're right. I was but now I've seen the light :).

        Many thanks Dave.

        Wylie