Skip to content

Instantly share code, notes, and snippets.

@timb-machine
Last active August 30, 2025 17:01
Show Gist options
  • Save timb-machine/bdae1fd4012f996dd13d5cba8a4155d0 to your computer and use it in GitHub Desktop.
Save timb-machine/bdae1fd4012f996dd13d5cba8a4155d0 to your computer and use it in GitHub Desktop.
encode-in-tree.pl
#!/usr/bin/perl
use Cwd;
use MIME::Base64;
$start = getcwd();
$maxnewpath = 1024;
while (sysread(STDIN, $byte, 1) != 0) {
$maxpath = 100;
$string = $byte;
while ((sysread(STDIN, $byte, 1) != 0) && ($maxpath > 0)) {
$string .= $byte;
$maxpath --;
}
$string .= $byte;
$string = encode_base64($string);
$string =~ s/\x0a//g;
$string =~ s/\x0d//g;
mkdir($string);
chdir($string);
$maxnewpath = $maxnewpath - length($string);
if (($maxnewpath - length($string)) < 0) {
chdir($start);
$maxnewpath = 1024;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment