Perl scripts and Pkunzip

How can I write a Perl script that will use PKUNZIP to unzip a specified file ?  Also is it possible to make the script check the error code that PKUNZIP returns and inform me if an error occured while trying to unzip a file ?

I would be grateful for all help offered regarding this.

John Clarke
Who is Participating?
mjswartConnect With a Mentor Commented:

$returnvalue = system("PKUNZIP", "");

Assuming you have "unzip" or "pkunzip" (depending on what system you are on)
then its dead easy...

if ($?) {
    print "Erorr occured unzipping\n";

You can also use the "system" call from within perl.

the $return is populated with any output from the "pkunzip"... however, ouput can go to STDERR so, you cannot determine success via this method.

To be 100% sure you should check the special variable $? which is set after a system call with the commands result code.  The above code illustrates this.

All Courses

From novice to tech pro — start learning today.