Front page | perl.beginners |
Postings from January 2004
Re: Zip using Perl
Thread Previous
|
Thread Next
From:
Adam
Date:
January 29, 2004 20:06
Subject:
Re: Zip using Perl
Message ID:
D01E01E4-525A-11D8-B500-000393D48B30@comcast.net
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" <lrlemieux@hotmail.com> 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: beginners-unsubscribe@perl.org
> For additional commands, e-mail: beginners-help@perl.org
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
>
>
Thread Previous
|
Thread Next