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

hi. i need help w/ the find2perl command. this is what i did:

find2perl $path -name $fName;

when i run the program and search for the files, it says:

Can't locate object method "name" via package "(the files)" (perhaps you forgot to load "bin "?) at ./perlrm line 19, <> line 2. what do i have to do to get this to work?

Replies are listed 'Best First'.
Re: find2perl help
by Limbic~Region (Chancellor) on May 04, 2003 at 23:44 UTC
    linuxfreak,
    find2perl is designed to convert a *nix style (though it works for Win32) find command into the equivalent perl code. You might use it as follows:
    $ find2perl / -name blah -exec rm {} \; > rmblah.pl $ chmod 500 rmblah.pl $ ./rmblah.pl
    It uses File::Find. It is not meant to actually be a line in your code like:
    #!/usr/bin/perl -w use strict; find2perl $path -name $fName;
    I would suggest you also take a look at File::Find::Rule. Once you get the hang of it, there really isn't any need to use find2perl unless you are porting someone else's obfu'd shell script that has some weird find command in it.

    Hope this helps - L~R

Re: find2perl help
by draconis (Scribe) on May 05, 2003 at 14:20 UTC
    Check out the @INC variable. Chances are that your package location is not included in @INC.