Perl Error In Option Spec Scalar
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Getops error in option spec up vote 0 down vote favorite I'm getting an error with the following script: my $h=""; my $r=""; my $i=""; my $n=""; my $forks=""; my $global=""; my $v=""; GetOptions ("h" => \$h, #print help "r" => \$r, #keep all temp folder "i" => \$i, #include additional config file "n" => \$n, #do not merge temp files "forks=f" => \$forks, #number of forks you want to use "global=g" => \$global, #special config line option "v" => \$v #verbose option ); The error is: "Error in option spec: global=g". Does anyone know a solution? Thank you! perl getopts share|improve this question edited Apr 27 '15 at 14:39 toolic 30.6k43468 asked Apr 27 '15 at 9:01 Darius 207 add a comment| 1 Answer 1 active oldest votes up vote 1 down vote g is not one of the supported option argument types. Using the "string" type, s, fixes the error: use warnings; use strict; use Getopt::Long; my $h=""; my $r=""; my $i=""; my $n=""; my $forks=""; my $global=""; my $v=""; GetOptions ("h" => \$h, #print help "r" => \$r, #keep all temp folder "i" => \$i, #include additional config file "n" => \$n, #do not merge temp files "forks=f" => \$forks, #number of forks you want to use "global=s" => \$global, #special config line option "v" => \$v #verbose option ); Refer to Summary of Option Specifications share|improve this answer answered Apr 27 '15 at 14:36 toolic 30.6k43468 add a comment| Your Answer draft saved draft discarded Sign up or log in Sign up using Google Sign up using Facebook Sign up using Email and Password Post as a guest Name Email Post as a guest Name Email discard By posting your answer, you agree to the privacy policy and terms of service. Not the answer you're looking for? Browse other questions tagged perl getopts or ask your own question. asked 1 year ago viewed 277 times active 1 year ago Related 272Using getopts in bash shell script to get lo
Categories 141.9K All Categories104.8K Programming Languages 6.4K Assembler Developer 1.9K Basic 39.9K C and C++ 4.3K C# 7.9K Delphi and Kylix 4 Haskell 9.6K Java 4.1K Pascal 1.3K Perl 2K PHP 526 Python 37 Ruby 4.4K VB.NET 1.6K VBA 20.8K Visual Basic 2.6K Game programming 312 Console programming 89 DirectX Game dev 1 Minecraft 110 Newbie Game Programmers 2 Oculus Rift 9K Applications 1.8K Computer Graphics 733 Computer Hardware 3.5K Database & SQL 534 Electronics http://stackoverflow.com/questions/29891337/getops-error-in-option-spec development 1.6K Matlab 628 Sound & Music 257 XML Development 3.3K Classifieds 198 Co-operative Projects 189 For sale 190 FreeLance Software City 1.9K Jobs Available 602 Jobs Wanted 203 Wanted 2.9K Microsoft .NET 1.7K ASP.NET 1.1K .NET General 3.4K Miscellaneous 6 Join the Team 0 User Profiles 354 Comments on this site 66 Computer Emulators 2.1K General https://www.programmersheaven.com/discussion/295790/weird-error-message programming 187 New programming languages 613 Off topic board 179 Mobile & Wireless 53 Android 124 Palm Pilot 335 Multimedia 151 Demo programming 184 MP3 programming 6.9K Operating Systems & Platforms 0 Bash scripts 22 Cloud Computing 365 Embedded / RTOS 53 FreeBSD 1.7K LINUX programming 369 MS-DOS 0 Shell scripting 320 Windows CE & Pocket PC 4.1K Windows programming 913 Software Development 409 Algorithms 68 Object Orientation 89 Project Management 90 Quality & Testing 256 Security 7.6K WEB-Development 1.8K Active Server Pages 61 AJAX 2 Bootstrap Themes 55 CGI Development 19 ColdFusion 224 Flash development 1.4K HTML & WEB-Design 1.4K Internet Development 2.2K JavaScript 35 JQuery 292 WEB Servers 154 WEB-Services / SOAP weird error message brtklt Member Posts: 237 March 2005 in Perl I got a 5 weird error messages that I have no clue what they are. The best I can do is show the code, the error output and hope someone knows what they are.[code]#!/usr/bin/perl -w #Load Modulesuse strict;use Getopt::Std;use Getopt::Long;use Pod::Usage; ###############################################
A • B • C • D • E F • G • H • I • L M • N • O • P http://perldoc.perl.org/Getopt/Long.html • S T • U • X Getopt::Long Perl 5 http://www.unix.com/shell-programming-and-scripting/130238-perl-getopt-long-question-stopping-multiple-args.html version 24.0 documentation Go to top • Download PDF Show page index • Show recent pages Home > Core modules (G) > Getopt::Long Please note: Many features of this site require JavaScript. You appear to have JavaScript disabled, or are running a perl error non-JavaScript capable web browser. To get the best experience, please enable JavaScript or download a modern web browser such as Internet Explorer 8, Firefox, Safari, or Google Chrome. Recently read Getopt::Long NAMESYNOPSISDESCRIPTIONCommand Line Options, an IntroductionGetting Started with Getopt::LongSimple optionsA little bit less simple optionsMixing command line option with other argumentsOptions with valuesOptions perl error in with multiple valuesOptions with hash valuesUser-defined subroutines to handle optionsOptions with multiple namesCase and abbreviationsSummary of Option SpecificationsAdvanced PossibilitiesObject oriented interfaceThread SafetyDocumentation and help textsParsing options from an arbitrary arrayParsing options from an arbitrary stringStoring options values in a hashBundlingThe lonesome dashArgument callbackConfiguring Getopt::LongExportable MethodsReturn values and ErrorsLegacyDefault destinationsAlternative option startersConfiguration variablesTips and TechniquesPushing multiple values in a hash optionTroubleshootingGetOptions does not return a false result when an option is not suppliedGetOptions does not split the command line correctlyUndefined subroutine &main::GetOptions calledHow do I put a "-?" option into a Getopt::Long?AUTHORCOPYRIGHT AND DISCLAIMERNAME Getopt::Long - Extended processing of command line options SYNOPSIS use Getopt::Long; my $data = "file.dat"; my $length = 24; my $verbose; GetOptions ("length=i" => \$length, # numeric "file=s" => \$data, # string "verbose" => \$verbose) # flag or die("Error in command line arguments\n");DESCRIPTION The Getopt::Long module implements an extended getopt function called GetOptions(). It parses the command line from @ARGV , re
Scripting BSD, Linux, and Unix shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here. Search Forums Show Threads Show Posts Tag Search Advanced Search Unanswered Threads Find All Thanked Posts Go to Page... unix and linux operating commands Perl Getopt::Long question - stopping multiple args Shell Programming and Scripting Page 1 of 2 1 2 > Thread Tools Search this Thread Display Modes #1 02-17-2010 rethink Registered User Join Date: Sep 2009 Last Activity: 18 June 2012, 9:10 AM EDT Posts: 121 Thanks: 3 Thanked 0 Times in 0 Posts Perl Getopt::Long question - stopping multiple args Hi there, I have an example basic script (below) and ive been trying to figure out how to stop multiple arguments to my options occuring. for example using the example script below I can issue two arguments for, say the --surname option and it will not barf at me (although thats what i want it to do). It just ignores the second argument to the --surname option completely and happily continues. Code: #./name.pl --firstname John --surname Smith Jones firstname is set to - John surname is set to - Smith How would i get it to barf at me for providing too many options ? Any help would be great The Script Code: #!/bin/perl use strict; use Getopt::Long; my $firstname = ""; my $surname = ""; my $help = ""; GetOptions ( "firstname=s" => \$firstname, "surname=s" => \$surname, "help!" => \$help, ) or die "Incorrect usage.\n"; if( $help ) { print "Common on, it's really not that hard.\n"; } else { if (!$firstname) { print "You have failed to enter a --firstname value\n"; exit 11 } if (!$surname) { print "You have failed to enter a --surname value\n"; exit 12 } print "firstname is set to - $firstname\n"; print "surname is set to - $surname\n"; } Remove advertisements Sponsored Links rethink View Public Profile Find all posts by rethink #2 02-17-2010 pludi Cat herder Join Date: Dec 2008 Last Activity: 28 March 2014, 8:35 AM EDT Location: Vienna, Austria, Earth Posts: 5,521 Thanks: 38 Thanked 335 Times in 308 Post