http://www.perlmonks.org?node_id=1069570


in reply to Re^2: how list all the files and directories?
in thread how list all the files and directories?

plz tell me wer im doing wrong

$path="D:/Chanti"; opendir ( DIR, $path ) || die "Error in opening dir $dirname\n"; #//print "directory contains-->@arr"; while($filename=readdir(DIR)){ print "$filename"; if (-f $filename){ push(@file,$filename); } if (-d $filename){ push(@dir,$filename); } } print "Directory--->@dir\n"; print "\n";print "\n";print "\n";print "\n";print "\n";print "\n"; print "File---->@file\n";

Replies are listed 'Best First'.
Re^4: how list all the files and directories?
by LanX (Saint) on Jan 06, 2014 at 19:24 UTC
    > plz tell me wer im doing wrong

    well use strict and use warnings would show you that $dirname doesn't exist.

    what else do you think is "wrong" in the result?

    Cheers Rolf

    ( addicted to the Perl Programming Language)