#!/usr/bin/env perl use strict; use warnings; my $chdir_to = shift; die "Usage: $0 DIRECTORY_TO_USE\n" unless defined $chdir_to; # MAXPATHLEN == 4096. 256 components. # 16 characters per component, including the trailing slash. for (my $i = 0; $i < 256; $i++) { chdir $chdir_to or die "chdir failed to $chdir_to: $!"; my $component = sprintf("%02x_____________", $i); mkdir $component, 0755 or die "mkdir failed (i = $i): $!"; $chdir_to = $component; } my @dirs = ( $chdir_to ); foreach (1..2) { $chdir_to =~ s/_//; mkdir $chdir_to, 0755; push @dirs, $chdir_to; } foreach my $dir (@dirs) { foreach my $file (qw( 1 22 333 )) { open OUT, '>', "$dir/$file" or die "unable to write $file: $!"; print OUT "non-empty\n"; close OUT; } }