Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^2: how list all the files and directories?

by littlemonk (Sexton)
on Jan 06, 2014 at 18:41 UTC ( #1069565=note: print w/replies, xml ) Need Help??


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

tried ignoring that "."

  • Comment on Re^2: how list all the files and directories?

Replies are listed 'Best First'.
Re^3: how list all the files and directories?
by LanX (Chancellor) on Jan 06, 2014 at 18:48 UTC
    the code "works" mostly, it's populating the arrays.

    you are just printing empty lines instead of the content of the arrays.

    Cheers Rolf

    ( addicted to the Perl Programming Language)

    update

    Plz be aware that you are excluding any file or dir starting with a dot.

    use strict; use warnings; use Data::Dump qw/pp/; my $path="/tmp"; opendir ( DIR, $path ) || die "Error in opening dir $path\n"; my (@file,@dir); while (my $filename=readdir(DIR)) { next if ($filename =~ m/^\./); if (-f $filename) { push(@file,$filename); # print "\n"; } elsif (-d $filename){ push(@dir,$filename); # print "\n"; } } pp \@file,\@dir;
Re^3: how list all the files and directories?
by littlemonk (Sexton) on Jan 06, 2014 at 19:01 UTC

    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";
      > 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)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1069565]
help
Chatterbox?
[Lady_Aleena]: Now I will see if my perl-fu is as bad as I think it is.
[shmem]: ah, geany uses its own idea of tags. Ah well...
[Lady_Aleena]: My perl-fu is bad.

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (7)
As of 2017-04-27 12:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (506 votes). Check out past polls.