develooper Front page | perl.beginners | Postings from December 2003

Re: Zip using Perl

Thread Previous | Thread Next
From:
R. Joseph Newton
Date:
December 19, 2003 21:40
Subject:
Re: Zip using Perl
Message ID:
3FE3E17F.83FED59B@efn.org
Manish Uskaikar wrote:

> Hi All,
>
> 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.

Not true.  I just tested, and filenames were not rejected for length.  It does not ignore whitespace, though, and there doesn't seem to be any way to escape whitespace characters.

> Since DOS does not support more than 8 characters.

Wouldn't make any difference on Win2K.  It doesn't use DOS for its command environment, although the interface does closely resemble DOS.  It is a shell escaping issue.

> Is there any way by which I can zip a file, whose name is 9+ characters long? I am working on Windows 2000.

Sure.  Just do it.  If your filename has spaces, you do have a problem.  I like the suggestion of using a module, since you are doing it from Perl.  No point in shelling out.  For what its worth, the program itself doesn't have any problem even with spaces in filenames.  I just zipped a directory with long filenames inside it, and they worked fine.  Thanks for letting me know about this command-line tool.

> Regards
>
> Manish U

Joseph


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About