mayank646 has asked for the wisdom of the Perl Monks concerning the following question:
Instead of $zip_file being hardcoded i want to take user input for the zip file name. I am using the following code#!/bin/perl use strict; use warnings ; use Archive::Zip; my $zip_file = 'file.zip' ; my $zip = Archive::Zip-> new (); $zip ->addTree( 'c:/zip'); $zip ->writeToFileNamed( $zip_file ); if (-e $zip_file) { print "Archive created successfully!"; } else{ print "Error in archive creation!"; }
here i am taking the input from the user and storing it in a variable $rn now i want to make the zip file with the name stored in the variable $rn.#! usr/bin/perl use Archive::Zip; # Getting Details print "Enter the Folder Name \n"; $rn = <>; print "The details are as follows: \n"; print "Release Name is *** $rn *** \n"; print "Business Unit is *** ABC *** \n"; print "Environment is *** ABC *** \n"; # Taking Backup my $zip_file = 'file.zip'; my $zip = Archive::Zip-> new (); $zip ->addTree( 'c:/zip'); $zip ->writeToFileNamed($zip_file); if (-e $zip_file) { print "Archive created successfully!"; } else{ print "Error in archive creation!"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Renaming a Zip file with a user input variable
by toolic (Bishop) on Aug 06, 2012 at 18:30 UTC | |
|
Re: Renaming a Zip file with a user input variable
by aitap (Curate) on Aug 06, 2012 at 19:46 UTC | |
|
Re: Renaming a Zip file with a user input variable
by rpnoble419 (Pilgrim) on Aug 06, 2012 at 21:33 UTC | |
by mayank646 (Initiate) on Aug 07, 2012 at 12:17 UTC |