in reply to globing directory names with spaces

you could use the quotemeta() function :
my $dir = shift; $dir = quotemeta( $dir ); @list = glod( "$dir/*.java" );
Using the angle brackets operator seems to work without quoting :
my $dir = shift; @list = <"$dir/*.java">;

Replies are listed 'Best First'.
Re: Re: globing directory names with spaces
by abhishes (Friar) on Sep 16, 2002 at 14:21 UTC
    works very well.

    But it list *.java files only of the directory which I
    specify.

    What can I do to make it list all the *.java diles in the
    direcotry which I specify and all its subdirectories as well?

    thanks for your reply.

    regards,
    Abhishek.
      Then you need to look into File::Find.
      use File::Find; my @java_file; find(sub { push @java_file, $File::Find::name if /\.java$/i }, "/desired/path");

      Makeshifts last the longest.

        Alternatively you could use File::Find::Rule
        use File::Find::Rule; my @files = File::Find::Rule->file() ->name('*.java') ->in('your/dir/here');
        Which will return a list of all the files with the .java extension in the given directory and all of it's subdirectories.
        HTH

        _________
        broquaint

        Hello All,
        thanks you so much for all the replies
        Here is what i wrote with File::Find
        #!/usr/bin/perl use strict; use warnings; use File::Find; my @java_files; my $pattern = shift; if ($pattern eq '') { print "defaulting the directory to the current one\n"; $pattern = '.'; } print "$pattern\n"; find(\&wanted, $pattern); foreach my $file (@java_files) { open OUTFILE, "$file"; while(<OUTFILE>) { print "$_\n"; } } my $java_files = @java_files; print "++ Total number of java files in project = $java_files\n"; sub wanted() { if (/\.java$/i) { push(@java_files, $_); } }
        The problem is that the contents of the files are not
        getting printed. because the file open is failing.
        the file open is failing because I have only the file name
        and not the complete path of the file. what can I do go get
        the complete file name in my java_file array?
      If you are getting that complicated maybe you should look at File::Find.

      --

      flounder