Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8468575
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T15:58:25+00:00 2026-06-10T15:58:25+00:00

I am writing a executable script(perl) that takes arguments from the command line. Here

  • 0

I am writing a executable script(perl) that takes arguments from the command line. Here is some different syntaxs, I can think of:

  1. myPerlScript 10 42
  2. myPerlScript myarg1=10 myarg2=42
  3. myPerlScript -myarg1=10 -myarg2=42
  4. myPerlScript myarg1 10 myarg2 42
  5. myPerlScript -myarg1 10 -myarg2 42

I do not like option 1. as it is not possible to give the arguments in arbitrary order, or skip the arguments to rely on default values. I would also like to give 2(or 3,…) dimensional arguments. Here are some examples again:

  1. myPerlScript myarg 10x20
  2. myPerlScript myarg=10x20
  3. myPerlScript -myarg 10x20
  4. myPerlScript -myarg=10x20
  5. myPerlScript -myarg=10 20
  6. myPerlScript -myarg=10,20

What is the recommended syntax? or what would you recommend? and does it depend on situations and/or what the script is used for?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T15:58:26+00:00Added an answer on June 10, 2026 at 3:58 pm

    I don’t know much about perl, but in ruby world (and the rest of unix that I can observe) this seems to be the most accepted idiom:

    myPerlScript --myarg1 10 --myarg2 42
    

    There’s a difference between single and double dash. Some commands have two forms: long (full command name) and short (a single letter, for brevity). Double dash is for long form, single – for short one. Real life example:

    mysql --user root
    mysql -u root
    

    I’d say that using single dash with long form will surprise people. Don’t do that 🙂

    And I also can recommend this excellent book: Building awesome command-line applications in Ruby. Although it will be of less value to you, because it’s in ruby, not perl.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing some code that uses dynamic shared libraries as plugins. My command line
I am writing an executable from a PowerShell script that needs to put the
Writing htaccess that allows me to remove index.php from the URL can confuse search
I'm writing a python script that uses subprocess.Popen to execute two programs (from compiled
I'm writing a Perl script that generates a Bash script. I'm using open() with
Let's say I am writing installation script for the program which contains executable file
Writing documentation in html requires some code examples. What to do with characters that
I am writing a PHP script designed to run an executable file (ffmpeg.exe) via
How can one loop a command/program in a Unix shell without writing the loop
When writing executable scripts, and declarative configuration files that use a common language (eg.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.