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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial

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.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.