in reply to Re: Need help with creating a filename only array
in thread Need help with creating a filename only array

That almost works. However, I just need the filename (minus the drive and path):

g:/this/that/other/somefile.txt needs to go into the array as somefile.txt

Your code above, while it gets rid of folders (including '.', '..'), puts the drive, path, and filename into the array (like above).

How do I get just the filename?

TIA

======================
Sean Shrum
http://www.shrum.net

  • Comment on Re: Re: Need help with creating a filename only array

Replies are listed 'Best First'.
Re: Re: Re: Need help with creating a filename only array
by flocto (Pilgrim) on Jul 27, 2002 at 07:20 UTC

    Oh.. Well, I tried to stick as close to your code as possible. This should work for you though:

    @files = grep { -f "$dir$_" } readdir (DIR);

    Simple, eh? ;)

    Regards,
    -octo

      Damn that was simple. I knew I was overthinking this thing. Perfect. Thanks again.

      ======================
      Sean Shrum
      http://www.shrum.net