in reply to Find file name

Apply a dash of File::Spec and a sprig of File::Find::Rule and you'll find yourself with a most pleasing result
use File::Spec; use File::Find::Rule; my @files = map { (File::Spec->splitpath $_)[-1] } find(file => name => "*ofas.db", in => $db_path);
That will function in a similar fashion to your find command except you'll get back a list of filenames instead a string of newline seperated filepaths.
HTH

_________
broquaint

Replies are listed 'Best First'.
Re: Re: Find file name
by blueapache (Acolyte) on Nov 11, 2003 at 16:36 UTC
    thanks, tried this but got Can't locate File/Find/Rule.pm in @INC guess that means its not available on our system. I'm new to this and I don't know how to tell what libraries/packages are installed
      If you've got privileged access to your machine then you can simply do
      perl -MCPAN -e 'install q[File::Find::Rule]'
      to install the module. However, if you're an unprivileged user you just need to set the path to somewhere that you can write to e.g
      shell> perl -MCPAN -e shell cpan shell -- CPAN exploration and modules installation (v1.65) ReadLine support enabled cpan> o conf makepl_arg PREFIX="/your/path/to/perl/lib"
      Or if you're installing from an unpacked tarball, just pass the PREFIX parameter to the Makefile.PL e.g
      perl Makefile.PL PREFIX=/your/path/to/perl/lib
      Then just add /your/path/to/perl/lib to @INC either through lib or the environment variable $PERL5LIB e.g
      use lib '/your/path/to/perl/lib'; use File::Find::Rule;
      HTH

      _________
      broquaint

        I'm definately an unprivileged user and
        shell> perl -MCPAN -e shell cpan shell -- CPAN exploration and modules installation (v1.65) ReadLine support enabled cpan> o conf makepl_arg PREFIX="/your/path/to/perl/lib"
        - what is this doing exactly ? I am interested but I doubt whether I could do this anyway for fear of messing the system up. Thanks