[ create a new paste ] login | about

Link: http://codepad.org/1jQpKm0f    [ raw code | output | fork ]

Perl, pasted on Jun 29:
my @wz = ();
getDirList(0, './');

my $file = "wztxt.txt" ;
print "\nwrite all texts in ./$file\n";
open FH, '>', $file or die $!;
map { print FH "$_\n" } @wz;
close FH;
exit 0;

sub getDirList {
	my ($depth, $subdirectory) = @_;

	opendir DIR, $subdirectory;
	my @files = readdir DIR;
	closedir DIR;

	for my $filename (@files) {
		my $path = $subdirectory . $filename;
		next if $filename eq '.';
		next if $filename eq '..';
		if (-d $path) {
			push @wz, '.'x $depth . $filename;
			getDirList($depth + 1, $path . '/');
		}
	}
}


Output:
1
2
3
4
5

write all texts in ./wztxt.txt
Permission denied at t.pl line 6.

Exited: ExitFailure 13


Create a new paste based on this one


Comments: