#!/usr/bin/perl
# move thru directories

use warnings;
#use strict;
use File::stat;

sub listdir {
	$dir = $_[0];
	opendir(D, "$dir");
	@list = readdir(D);			
	contentof();
	selecta();
}
	
sub selecta {
	print "\nwhich directory (#): ";
	$new = <>;
	closedir(ND);
	listdir($new);
}

sub contentof {
	opendir(D, "$dir");
	@list = readdir(D);			
	$num = 0;
	foreach $file (@list) {
		if ( -d $file ) {
			print "$num: $file\n";
			$dirlist[$num] = $file;
			$num++;			# increment $num
		}
	}
}

$dir = $ARGV[0];		# stat (eg) won't deal w/ @ARGV
print "directory $dir --\n";
contentof();
closedir(D);
$chuck = <>;			# deals with a strange extra stdout->stdin return
selecta();

