Re: problem about the perl code. thanks for any comments
- From: "A. Sinan Unur" <1usa@xxxxxxxxxxxxxxxxxxx>
- Date: Tue, 30 Aug 2005 20:55:57 GMT
"yezi" <ye_line@xxxxxxxxxxx> wrote in news:1125434263.574194.118650
@z14g2000cwz.googlegroups.com:
> 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.
Please post code that others can run by just copying and pasting. That
means no line numbers.
use strict;
use warnings;
missing.
> 24 opendir DIR,".";
Always, always check the return value of system calls
opendir my $current_dir, '.'
or die "Cannot open current directory: $!";
> 25 @files = readdir DIR;
> 26 foreach $file (@files)
> 27 {
> 28 if ($file =~ /\.RD/)
> 29 {
my @files = grep { /\.RD$/ } readdir $current_dir;
closedir $current_dir
or die "Cannot close current directory: $!";
for my $file (@files) {
> 30 $sitename=chomp($file);
1. Why are you chomping $file?
2. What do you thing chomp returns?
In all likelihood, $sitename is now set to 0.
Please read the posting guidelines for this group to lern how you can
help yourself, and help others help you.
Sinan
--
A. Sinan Unur <1usa@xxxxxxxxxxxxxxxxxxx>
(reverse each component and remove .invalid for email address)
comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
.
- Follow-Ups:
- References:
- Prev by Date: Re: DBI prepare and fetch
- Next by Date: Re: File with hash inside it
- Previous by thread: problem about the perl code. thanks for any comments
- Next by thread: Re: problem about the perl code. thanks for any comments
- Index(es):