#!/usr/bin/env perl use v5.36; use Getopt::Std; use feature qw/switch/; no warnings q/experimental::for_list/; sub HELP_MESSAGE { ...; exit } my $verbose; my $force; my $table; my %opts; HELP_MESSAGE() if !getopts( 'hvft:', \%opts ); for my ( $k, $v ) (%opts) { given ($k) { when ('h') { HELP_MESSAGE(); } when ('v') { ++$verbose; } when ('f') { ++$force; } when ('t') { $table = $v; } default { die "*** BUG: no handler for -$k.\n"; } } } #### for my ( $k, $v ) (%opts) { if ( $k eq 'h' ) { HELP_MESSAGE(); } elsif ( $k eq 'v') { ++$verbose; } elsif ( $k eq 'f') { ++$force; } elsif ( $k eq 't') { $table = $v; } else { die "*** BUG: no handler for -$k.\n"; } }