Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] [PERL] How to pass "+" character to perl?

Status
Not open for further replies.

maulin sheth

Advanced Member level 2
Advanced Member level 2
Joined
Oct 24, 2010
Messages
502
Helped
90
Reputation
179
Reaction score
90
Trophy points
1,318
Location
Bangalore, India
Visit site
Activity points
4,161
Hello All,

How to pass + character through command line in perl?
e.g.
perl temp.pl -ComndOpts=+vcs -full64.
Now, I have to pass +vcs and -full64 both using single command line option "ComndOpts". as There is not any limit for "ComndOpts" as it may have 2 arguments/ 3 arguments/4 arguments or whatever(maximum 7-8).
So how I can pass these arguments to script temp.pl?

Thanks in advance.

-Maulin Sheth
 

Hi maulin sheth,
Have you tried with ARGV command. This will retrive the command line value

printf "$ARGV[0]\n";
printf "$ARGV[1]\n";

If u add the above command in temp.pl it will print -ComndOpts=+vcs and -full64. $ARGV[0] will have -ComndOpts=+vcs $ARGV[1] will have -full64.
 

Hello,
Thanks for help.
But I want to do it using GetOptions only. So How can I do that?
perl temp.pl -ComndOpts +vcs -full64.
I want to use like : ComndOpts variable which is equal to "+vcs -full64". So I want to pass this varialbe through command line and using GetOptions only.
So please can anyone help me to solve this?

Thanks in advance.

-Maulin Sheth
 

Hi maulin sheth,

For ur requirement Is there any possibity to send with "" while passing. If u can then its easier use the below code.

perl try2.pl -ComndOpts="+vcs -full64"

Code:
use Getopt::Long;
GetOptions("ComndOpts:s" => \$ComndOpts);
print $ComndOpts;
 

Hello,
Thanks.
I have solved this by using following code :
perl try2.pl -ComndOpts "+vcs -full64"
code :
Code:
use Getopt::Long;
GetOptions("ComndOpts=s" => \$ComndOpts);
print $ComndOpts;

In this code, change is just : ComndOpts:s to ComndOpts=s.

-Maulin Sheth
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top