Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

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

by LanX (Chancellor)
on Jan 06, 2014 at 18:48 UTC ( #1069567=note: print w/replies, xml ) Need Help??

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

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)


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;

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1069567]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (10)
As of 2016-10-27 20:41 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (371 votes). Check out past polls.