snafu has asked for the wisdom of the Perl Monks concerning the following question:

perl -e 'eval{system(find2perl find . -name *08??.ama.gz -ls)}';

$ perl -e 'eval{system(find2perl find . -name *08??.ama.gz -ls)}'; Illegal octal digit at -e line 1, at end of line Search pattern not terminated at -e line 1.

Im just trying to do a find using Perl + find2perl + my find params.

I would much rather do things purely in Perl rather than running a system() command with my find + params. So I decided to try this coding route. I realize it may not be the most efficient in terms of a production program but I would like to know if I am on the right track as far as making this work.

Feel free to give any pointers on how to do the same thing *easily* in a production script.

----------
- Jim

Replies are listed 'Best First'.
Re: Is it possible to use find2perl like this?
by stefp (Vicar) on Sep 18, 2001 at 01:00 UTC
    find2perl . -name "*08??.ama.gz" -ls | perl
    You were tricked because you need to quote to differ the globbing. It must be done by the finder (whichever it is) not by the shell that calls it. If you want to do everything within one perl process. You must deal directly with File::Find.

    -- stefp

Re: Is it possible to use find2perl like this?
by derby (Abbot) on Sep 18, 2001 at 01:29 UTC
    Jim, How about something along these lines:
    #!/usr/local/bin/perl -w use strict; use File::Find; find(\&wanted, '.' ); sub wanted { print $File::Find::name, "\n" if( /08.*ama.gz/ ); }
    -derby