Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Hi all, I am trying to rename a zip file with the user input. I have tried but when i am giving the variable its making a file with the vairiable name only like $abc not with the value stored in the variable.
#!/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!"; }
Instead of $zip_file being hardcoded i want to take user input for the zip file name. I am using the following code
#! 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!"; }
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.

In reply to Renaming a Zip file with a user input variable by mayank646

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2024-04-25 23:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found