I think all that is happening is that for some reason, you can't create a directory "IO". You don't check the return value of mkdir, you better would. Maybe like this, eliminating use of the database entirely:
my $dir = 'IO';
mkdir $dir or die "Can't create directory: $!" unless -d $dir;