I am new to perl but after spending late nights for some days , i was able to generate code for database backup. the code will ask you enter servername , enter database name if i enter it will take backup suppose my code is in backup.pl now the thing is i need to get database backup by entering like this perl backup.pl -i servername -d databasename if i hit enter it should take backup of given server name and database name.

My code:

use strict; use Win32::SqlServer qw(SCALAR); print "Please enter DB name:\n"; my $name = <STDIN>; chomp($name); # Log in to server . my $sqlsrv = Win32::SqlServer::sql_init('localhost', 'geff', 'gentle', + 'Northwind'); # Our SQL statement. my $stmnt = <<SQLEND; BACKUP database "$name" TO DISK = N'c:\\bak\\master.dmp' SQLEND # Run query. my $result = $sqlsrv->sql($stmnt, SCALAR); # Print results. foreach my $name (@$result) { print "$name\n"; }

In reply to need help urgent using @ARGV by mohan@1

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.