Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Re^2: globing directory names with spaces

by abhishes (Friar)
on Sep 16, 2002 at 15:24 UTC ( [id://198267]=note: print w/replies, xml ) Need Help??


in reply to Re^2: globing directory names with spaces
in thread globing directory names with spaces

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?

Replies are listed 'Best First'.
Re^4: globing directory names with spaces
by Aristotle (Chancellor) on Sep 16, 2002 at 16:49 UTC
    Did you read my reply? You would have noticed I was using $File::Find::name rather than $_ in the sub I pass to find because I anticipated just that problem. :-) See the docs to File::Find for more details.

    Makeshifts last the longest.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://198267]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2024-07-24 21:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.