if (@ARGV == 2) { $result = ">" . pop(@ARGV); # removes element from @ARGV # ... } elsif (@ARGV == 3) { $result = ">" . pop(@ARGV); $name = pop(@ARGV); # ... }