in reply to How to use variables in @INC and "use" commands

or 'eval' the use:
eval('use dir_'.$day.'::'.$userId.' qw(\%diary)'); print "Can't use dir_$day::$userId module: $@";
If you choose to use require, beware that if you give it a string, it expects it to be a file name/path, not the module name.