I'd be interested in seeing the error message if you could provide it. Given your message, the only problem I could see with this code is if the file's name had spaces. For example, if you attempted to zip a file named `my grocery list.xls`. You would need to wrap the zip name in single quotes or escape out the spaces.

Something like this should work:

#! /usr/bin/perl

use strict;

my($file_nm);

# Retrieve the namme of the file to archive.
print("Name the file to archive: ");
chomp($file_nm = <STDIN>);

# Confirm the file exists, if not exit the program.
(-e $file_nm) or die("Cannot find file `$file_nm`.\n");

# Zip the file.
print("Trying file name '$file_nm.zip'");
system("zip '$file_nm.zip' '$file_nm'");

Regards,
Adam

Does the file's name contain spaces?
On Jan 29, 2004, at 1:24 AM, Owen wrote:

On Wed, 28 Jan 2004 15:37:12 -0500
"RL" <[EMAIL PROTECTED]> wrote:

I would like to "zip" a file using perl script. I used following command:-

system ("zip <zip name> <file name>");

However this command fails when the filename is more than 8 characters.



I really have no idea.


have you tried


system ("zip <eightchr.zip> <file name>")


rename ("eightchr.zip","nine_or_more_characters.zip")


-- Owen


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to