in reply to filenames with spaces causing problems

Instead of using ls you could just use perl e.g
use IO::Dir; my @files = grep -f, IO::Dir->new(".")->read;
That's just one simple approach, whereas you may prefer to expand it using opendir and readdir or even File::Find::Rule.
HTH

_________
broquaint

Replies are listed 'Best First'.
Re: Re: filenames with spaces causing problems
by drake50 (Pilgrim) on Jul 11, 2003 at 12:44 UTC
    Yeah but I don't always want to do every file or directory. I'd rather be able to pass a list as an argument so the program is more flexable.
      Then pass in the directory that you're listing, and better still, use that in conjunction with File::Find::Rule e.g
      use File::Find::Rule; my $dir = shift; die "$0: invalid directory $dir\n" unless -d $dir; my @files = find( name => '*.mp3', in => $dir );
      I think you'll find that you'll be able to get a lot more flexibility and extensibility if you build the file listing into the program (not that there's anything wrong with using command line tools of course).
      HTH

      _________
      broquaint