Re: problem about the perl code. thanks for any comments
- From: Big and Blue <No_4@xxxxxxxxxxxxx>
- Date: Wed, 31 Aug 2005 00:20:57 +0100
yezi wrote: >
Hi all: the following is my program , Do not know why it can not open file (*.RD ) in the current directory. Thanks for any comments.
As has been pointed out - checking and printing the results of opendir and open will tell you that.
Other comments...
24 opendir DIR,".";
25 @files = readdir DIR;
You've forgotten the closedir().
26 foreach $file (@files)
Why not just loop on the readdir DIR, rather than slurping it into an array?
27 {
28 if ($file =~ /\.RD/)
29 {
30 $sitename=chomp($file);
Why are you chomp()ing? You are reading entrynames from a directory - if any of them ends with your $/ contents then it really does need them.
--
Just because I've written it doesn't mean that
either you or I have to believe it.
.- Follow-Ups:
- References:
- Prev by Date: Re: A program to measure flops in Perl (should it be this "off"?)
- Next by Date: Re: A program to measure flops in Perl (should it be this "off"?)
- Previous by thread: Re: problem about the perl code. thanks for any comments
- Next by thread: Re: problem about the perl code. thanks for any comments
- Index(es):