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 830173
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T04:00:03+00:00 2026-05-15T04:00:03+00:00

If I have a command line like: my_script.pl -foo -WHATEVER My script knows about

  • 0

If I have a command line like:

my_script.pl -foo -WHATEVER

My script knows about --foo, and I want Getopt to set variable $opt_foo, but I don’t know anything about -WHATEVER. How can I tell Getopt to parse out the options that I’ve told it about, and then get the rest of the arguments in a string variable or a list?

An example:

use strict;
use warnings;

use Getopt::Long;

my $foo; 

GetOptions('foo' => \$foo); 

print 'remaining options: ', @ARGV;

Then, issuing

perl getopttest.pl -foo -WHATEVER

gives

Unknown option: whatever
remaining options:
  • 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-05-15T04:00:05+00:00Added an answer on May 15, 2026 at 4:00 am

    You need to configure “pass_through” option via Getopt::Long::Configure("pass_through");

    Then it support actual options (e.g. stuff starting with “-” and without the special “–” delimiter to signify the end of “real” options).

    Here’s perldoc quote:

    • pass_through (default: disabled)

      Options that are unknown, ambiguous or supplied with an invalid option value are passed through in @ARGV instead of being flagged as errors. This makes it possible to write wrapper scripts that process only part of the user supplied command line arguments, and pass the remaining options to some other program.

    Here’s an example

    $ cat my_script.pl
    #!/usr/local/bin/perl5.8 -w
    
    use Getopt::Long;
    Getopt::Long::Configure("pass_through");
    use Data::Dumper;
    my %args;
    GetOptions(\%args, "foo") or die "GetOption returned 0\n";
    print Data::Dumper->Dump([\@ARGV],["ARGV"]);
    
    $ ./my_script.pl -foo -WHATEVER          
    $ARGV = [
              '-WHATEVER'
            ];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 498k
  • Answers 498k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer This XSLT 1.0 stylesheet: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="node()|@*"> <xsl:copy>… May 16, 2026 at 12:16 pm
  • Editorial Team
    Editorial Team added an answer ''.join([s for s in string1 if s in a]) Explanation:… May 16, 2026 at 12:16 pm
  • Editorial Team
    Editorial Team added an answer I did exactly like you : add some delay and… May 16, 2026 at 12:16 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

The (command line) interface I have in mind is like so: watching FILE+ do
Let's say I have a Bash script called foo.sh . I'd like to call
I'd like to prevent multiple instances of the same long-running python command-line script from
I want to write a script foo which simply calls bar with the exact
I have a command that works great on the command line. It has lots
I have a perl script that is only keeping the last set of records
My company has traditionally used a Linux command line development environment. We use a
I have a simple python script that just takes in a filename, and spits
I have some R code inside a file called analyse.r. I would like to
I want to debug TCP/IP interactions for a program I'm enhancing. I don't have

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.