use File::Path;
mkpath(/storage/systbl/, 0, 0777) || die $!\n;
in accordance with the prophecy.
-Original Message-
From: loan tran [mailto:[EMAIL PROTECTED]]
Sent: Thursday, October 10, 2002 5:26 PM
To: [EMAIL PROTECTED]
Subject: how to check if a dir exists if not create it?
Check out the file test man pages:
perldoc -f -x
-Original Message-
From: loan tran [mailto:[EMAIL PROTECTED]]
Sent: Thursday, October 10, 2002 2:26 PM
To: [EMAIL PROTECTED]
Subject: how to check if a dir exists if not create it?
mkdir (/storage/systbl/) || die $!\n;
The code above
Loan Tran [EMAIL PROTECTED] wrote:
mkdir (/storage/systbl/) || die $!\n;
The code above does not check if the dir exist.
Can you modify it please. Thanks.
You can check whether a directory exists with the -e
and -d file test operators.
$ perldoc -f -X
But as soon as you write code like:
Loan Tran wrote:
mkdir (/storage/systbl/) || die $!\n;
The code above does not check if the dir exist.
Can you modify it please. Thanks.
try:
#!/usr/bin/perl -w
use strict;
use File::Path;
my $dir = '/a/long/not/existing/dir';
mkpath($dir) || die no permission to $dir?;
print done\n
Thank you all for your reply.
I greatly appreciate your help.
Loan
--- Steve Grazzini [EMAIL PROTECTED] wrote:
Loan Tran [EMAIL PROTECTED] wrote:
mkdir (/storage/systbl/) || die $!\n;
The code above does not check if the dir exist.
Can you modify it please. Thanks.
You can check