Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Simple Getopt::Long Question

Posted on 2005-03-03
Medium Priority
Last Modified: 2010-03-05
use Getopt::Long;

#Get command line parameters
GetOptions("City=s",\$City, "State=s",\$State);

print "City: $City\n";
print "State: $State\n";

If I call this using the following: Test.pl -City Boston -State MA

The output is correct
City: Boston
State: MA


If I use a city with a space for exampe: Test.pl -City New York -State NY

The output only grabs 'new' for the city name.
City: New
State: NY

How can I pass in a string with a space in it on the command line using GetOpt:Long?

Question by:maddhacker24
1 Comment
LVL 16

Accepted Solution

manav_mathur earned 200 total points
ID: 13450306
Enclose the string on command line within quotes.


Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans
Suggested Courses

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question