#!/usr/bin/perl -w use Cwd; sub MakeDirs($$$) { #my $current_dir = getcwd(); my($base, $num_dirs, $depth) = @_; #if depth = 0, no more subdirectories need to be created if($depth == 0) { return 0; } #change the directory chdir $base; #Create directories on the current level my $dir_name = "a"; for($x = 0; $x < $num_dirs; $x++) { mkdir $dir_name; $dir_name++; } #recurse over subdirectories $dir_name = "a"; for($x = 0; $x < $num_dirs; $x++) { MakeDirs($dir_name, $num_dirs, $depth-1); $dir_name++; } return 0; } MakeDirs("/hpq/", 2, 3);