if (! mkdir $dir)

J

joez3

I have the following if statment in some code that I got at work:
if (! mkdir $dir)
When I try to run this code no matter what I set $dir to it fails with:
Not enough arguments for mkdir at test.pl line 11, near "$dir ) "
Execution of test.pl aborted due to compilation errors.

Why doesn't this code work on windows? Is there a way to make it work?
Thanks,
Zim
 
J

jl_post

if (! mkdir $dir)

When I try to run this code no matter what I set $dir to it fails with:
Not enough arguments for mkdir at test.pl line 11, near "$dir ) "
Execution of test.pl aborted due to compilation errors.


If you're using an older version of Perl, the mkdir() function may
be expecting a MASK parameter. Type "perldoc -f mkdir" to see if this
additional parameter is required (which I suspect is the case).

If that's the case, try changing your line to:

if (! mkdir $dir, 0777)

and see if that works.

I hope this helps, Zim.

-- Jean-Luc
 
K

Keith Thompson

If you're using an older version of Perl, the mkdir() function may
be expecting a MASK parameter. Type "perldoc -f mkdir" to see if this
additional parameter is required (which I suspect is the case).

If that's the case, try changing your line to:

if (! mkdir $dir, 0777)

and see if that works.

You might just go ahead and make that change anyway. In the latest
versions of Perl, the mask argument is optional and defaults to 0777;
supplying a value of 0777 should be harmless.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,169
Messages
2,570,916
Members
47,458
Latest member
Chris#

Latest Threads

Top