in reply to Optionally include named arguments when constructing a new object
Getopt::Long can be set to carp/croak when your script doesn't have all the required items, which may come in handy as well.use strict; use warnings; use Getopt::Long; my %opts; GetOptions( 'address=s' => sub { $opts{$_[0]} = $_[1]; } 'user=s' => sub { $opts{$_[0]} = $_[1]; } 'pass=s' => sub { $opts{$_[0]} = $_[1]; } 'protocol=s' => sub { $opts{$_[0]} = $_[1]; } 'snmp_community=s' => sub { $opts{$_[0]} = $_[1]; } 'snmp_port=s' => sub { $opts{$_[0]} = $_[1]; } 'snmp_timeout=s' => sub { $opts{$_[0]} = $_[1]; } ... }
|
|---|