my ($input,$stat,$csv); while (my $arg = shift @ARGV) { if ($arg eq "-i") { $input = shift @ARGV; } elsif ($arg eq "-s") { $stat = shift @ARGV; } elsif ($arg eq "-o") { $csv = shift @ARGV; } else { die "$arg: invalid argument\n"; } defined $input && defined $csv && defined $stat || die "You should define -i, -o and -s!\n";