Our project has many testing platforms, including Windows and Linux. Linux provides an unzip command for decompression, but it is troublesome in windows. in Windows 2000, no command is provided to decompress the file. In XP, The unzip command is provided, but there is no such command in Vista.
This is very troublesome. You cannot simply Extract files by using the commands provided by the operating system. Therefore, I wrote a script to handle this need.
In Linux, I will not write it, as long as the unzip command is used, it is very simple.
The following describes the modules used to solve windows problems.
Perl provides an archive package to solve the problem of decompression and File compression.
I simply applied the package decompression function.
-
- #! /Usr/bin/perl-W
-
-
- My ($ File,$ Targetdir) = @ Argv;
-
- If(! Defined ($ Targetdir)){
-
- $ Targetdir=".";
- Print"Unzip $ file to current dir.../N";
-
- }Else{
-
- Print"Unzip $ file to $ targetdir.../N";
-
- }
-
- UseArchive: Extract;
-
- My$ Ar= Archive: extract->New(Archive =>$ File);
- My$ OK=$ Ar-> Extract (to =>$ Targetdir)Or Die;
This script is mainly used to extract the specified compressed file to the specified directory. If the directory is not specified, extract it to the current directory.
In this way, you only need to call the script when extracting files on various platforms, and you only need to provide the path. Instead of writing data based on the systemCode.
:-D.