in reply to readdir return nul string
opendir (DIR,dirname); @dir = grep{!/^\.+/} readdir(DIR); closedir(DIR); print join("\n",@dir);
It will print all the files and the sub directories expect '.' and '..'.
here i modified your code ...
opendir( DIR, $directory ) or die "open dir error"; my $number = 0; while(defined($name = readdir (DIR))) { if($name eq "") { print "Value -$name* is null string." } next if ($name eq "." || $name eq ".."); $number++; print "Loop $number-->$name**\n"; # next unless $name =~ /(.*)\.lip$/; push @names, $name; }
|
|---|