$ perl -Mstrict -Mwarnings -E ' use Getopt::Long; sub sub1 { state $i = 0; ++$i; say "$i: >>>$_<<<" for @_ } GetOptions( "test=s{3}" => \&sub1 ); ' -- --test a b c 1: >>>test<<< 1: >>>a<<< 2: >>>test<<< 2: >>>b<<< 3: >>>test<<< 3: >>>c<<<