Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Default values for Getopt::Long

Status
Not open for further replies.

mohankrishna919

Programmer
Jan 18, 2012
14
US
his is second perl file code which i am calling first perl file

#!/usr/bin/perl
use warnings;
use strict;
use Getopt::Long;
use Win32::SqlServer qw(SCALAR);
GetOptions(
'i=s' => \ my $servername,

'c=s' => \ my $code,

);
system( "start perl $code -i $servername -d msdb ");
I am calling this file as perl filename2.pl -i test -c filename1.pl
It rans fine but if ran like perl filename2.pl -i test -c filename1.pl - TYPE full

its throwing error as unknown option type.

That's because filename2.pl is seeing "-TYPE full" as arguments to it, not arguments to filename1.pl. And since you haven't told filename2.pl about the -TYPE argument in its GetOptions() call, it throws an unknown argument error.

TYPE parameter belongs to filename1.pl
I need to pass TYPE parameter to filename1.pl during execution of filename2.pl
Is that possible?
Please suggest
 
Could be challenging with Windows strange (to my mind) quote handling, but try this:

Code:
perl filename2.pl -i test -c "filename1.pl -TYPE full"

Annihilannic
[small]tgmlify - code syntax highlighting for your tek-tips posts[/small]
 
Also on the subject of "please guide me"... I recommend you give your Tek-Tips threads meaningful names, which would generate more interest and accurate answers. Something like "Default values for Getopt::Long" or "Calling one perl script from another with options" would be much better.

Annihilannic
[small]tgmlify - code syntax highlighting for your tek-tips posts[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top