The shift operator returns an undefined value if the array has no more elements.
#!/usr/bin/perl -w
# Get first argument.
$arg = shift(@ARGV);
# Loop while there is an argument.
while (defined $arg) {
print "$arg\n";
# Get next argument.
$arg = shift(@ARGV);
}