Hey there :)
i am trying this part of code, which testing arguments on command line:

use Getopt::Long;

GetOptions(
    "verbose" => \$verbose,
    "get" => \$get
);

print "verbose = $verbose\n";
print "get = $get\n";

In my script i have several arguments, with which my script working (any sequence).

In this code isn't distinguish, when the user enters '--get' or '-get' - and this is my problem - i don't know, how the code to adjust.. :/
(I have to use the module GetOpt::Long)

Thank you for your tips.

I found this code example

use Getopt::Long;
my $data = "file.dat";
my $length = 24;
my $verbose;
$result = GetOptions ("length=i" => \$length, # numeric
                      "file=s" => \$data, # string
                      "verbose" => \$verbose); # flag

at http://perldoc.perl.org/Getopt/Long.html

(The first page returned for google "perl getopt long")

If you've read through that page and still have questions, post specific questions with a little more detail on what it does now vs what you want it to do.

Uhh.. well how i can distinguish, if the user entered '-verbose' or '--verbose'??? This is the thing, what i don't know... :/

With the bundling option, whether the parameter is entered with one or two dashes does make a difference. For example:

#!/usr/bin/perl
#OneDashOrTwo.pl
use 5.006;
use strict;
use warnings;

use Getopt::Long qw(:config bundling);

my ($verbose, $get, $v, $g);
GetOptions(
    "verbose" => \$verbose,
    "get" => \$get
);

print "verbose = $verbose\n";
print "get = $get\n";

Not to be rude about it, but why do you care if the user entered '-verbose' or '--verbose'?

If they both make the output verbose, why should they care?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.