CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Creating a Directory

 



Beng
Deleted

May 14, 2001, 12:21 PM

Post #1 of 3 (860 views)
Creating a Directory Can't Post

I am modifying a perl script that unzips any zip files located in a directory. If I try to create a directory for each zip file to unzip to it bombs out. IE if we have a file called PollLogs.zip it would create a Directory called PollLogs.Zip. It will not create the directory, but it will unzip it in to the directory it is in.

Here is a sample of my code. If anyone could help I would appreciate it. Thanks.

foreach $file (@filelist)
{

chdir ($dirname.unzipped);
mkdir $file, 0777;


@args = ("wzunzip.exe", "-ybc", $file, "$dirname\\$file");
system(@args) == 0
or die "Unable to run wzunzip on $file Aborting \n";

$exit_value = $? >> 8;
if($exit_value == 0)
{
print "Successfully unzipped $file with return code of $exit_value \n";
}
else
{
print "Failed to unzip $file with return code of $exit_value \n";
die "Failed to unzip $file with return code of $exit_value";
}


# If we're suppose to delete these files do so.
if($filedelete == 1)
{
$cnt = unlink $file;
if($cnt != 1)
{
print "Unable to delete $file";
}
}
}



widexl
Novice

May 15, 2001, 7:52 AM

Post #2 of 3 (846 views)
Re: Creating a Directory [In reply to] Can't Post

I don't now it on windows.
But try:

$dir = "c:/full/dir";
$mkdir = "$dir/$file";
mkdir $mkdir, 0777;

I think you need the full path.

Henk



freddo
User

May 16, 2001, 10:23 AM

Post #3 of 3 (834 views)
Re: Creating a Directory [In reply to] Can't Post

Hi Beng,

In windows, you cant have a file and a directory having the same name, try to remove the .zip from the filename with something like $dirname = substr($file,0,-4);.

Hope this helps
Freddo

;---
Real programmers don't eat cache.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives