marscld has asked for the wisdom of the Perl Monks concerning the following question:
I've encounted a weird problem.Basically, I wanna read entries in a directory and opendir works. However, the readdir just return null strings instead of file names, I'm so confused.
If there are 5 files in $directory, what I got is 7 ''.
Code:
opendir( DIR, $directory ) or die "open dir error"; my $number = 0; while(defined($name = readdir (DIR))) { $number++; if($name eq "") { print "Value -$name* is null string." } print "Loop $number-->$name**\n"; next if $name eq "." || $name eq ".."; next unless $name =~ /(.*)\.lip$/; push @names, $name; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: readdir return nul string
by oha (Friar) on Sep 26, 2007 at 10:00 UTC | |
|
Re: readdir return nul string
by perlofwisdom (Pilgrim) on Sep 26, 2007 at 11:40 UTC | |
by marscld (Beadle) on Sep 26, 2007 at 13:15 UTC | |
|
Re: readdir return nul string
by sankarraman (Acolyte) on Sep 26, 2007 at 13:35 UTC | |
|
Re: readdir return nul string
by Aim9b (Monk) on Sep 26, 2007 at 10:59 UTC | |
by Fletch (Bishop) on Sep 26, 2007 at 13:00 UTC | |
by Aim9b (Monk) on Sep 26, 2007 at 18:50 UTC | |
by Fletch (Bishop) on Sep 26, 2007 at 19:32 UTC | |
by Aim9b (Monk) on Sep 27, 2007 at 21:50 UTC |