#!/bin/perl use strict; use Getopt::Long; my @words; my $wordsub = sub { while (@ARGV){ if ( $ARGV[0] !~ /^-/ ){ push @words, shift @ARGV } else { last } } }; GetOptions('words' => $wordsub);