littlemonk has asked for the wisdom of the Perl Monks concerning the following question:
i am trying to list all the directories and files and store them in an array ,but dont why this is not working..where i am doing mistake?plz help thank you!
$path="D:/Chanti"; opendir ( DIR, $path ) || die "Error in opening dir $dirname\n"; while($filename=readdir(DIR)){ next if ($filename =~ m/^\./); if (-f $filename){ push(@file,$filename); print "\n"; }else if (-d $filename){ push(@dir,$filename); print "\n"; } }
its not listing all the directories except ".." and "." remaining all are going as files
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: how list all the files and directories?
by toolic (Bishop) on Jan 06, 2014 at 18:52 UTC | |
|
Re: how list all the files and directories?
by jellisii2 (Hermit) on Jan 06, 2014 at 21:11 UTC | |
by DrHyde (Prior) on Jan 07, 2014 at 11:28 UTC | |
|
Re: how list all the files and directories?
by Laurent_R (Canon) on Jan 06, 2014 at 18:47 UTC | |
|
Re: how list all the files and directories?
by LanX (Saint) on Jan 06, 2014 at 18:33 UTC | |
by littlemonk (Sexton) on Jan 06, 2014 at 18:41 UTC | |
by LanX (Saint) on Jan 06, 2014 at 18:48 UTC | |
by littlemonk (Sexton) on Jan 06, 2014 at 19:01 UTC | |
by LanX (Saint) on Jan 06, 2014 at 19:24 UTC |