Search code examples
linuxperldirectorymkdir

Create directory by mkdir


I want to create a folder named by the user name in /tmp/vnc/, I can create that folder in command line with perl -e 'mkdir("$ENV{USER}")', but for the following code cannot work.

chdir ("/tmp/vnc") or die -1;
mkdir ("$ENV{USER}", 0777) or die -1;

If I use mkdir -p /tmp/vnc/$ENV{USER} in command line to make folder, nothing happens and no error reports.


Solution

    1. Please check special variable $! for text error message
    2. Please check that variable $ENV{USER} doesn't contain extra quotes. I had similar problem in Windows OS for Activer Perl. My problem was in extra quotes