in reply to Receiving Standard Input/Piped

(Update: mis-read your question, but still applies. Some text below updated to match your request.)

If your task is simple or straightforward, you may just get away with the magic <> line iterator. This automatically pulls from each named file in turn, or from STDIN if there was none. This handles both of your cases magically.

# receive a list of filenames on stdin # (or from an intermediary file named on command line) # while (<>) { chomp; # process a filename in $_ }
If you're new to Perl, I would also try to ween you away from "index loops" and toward iterating over the elements. You will find that you rarely NEED the integer representing the current position in a group of things.
# index loop for my $f (0 .. $#array) { my $g = $array[$f]; ... } # element loop for my $g (@array) { ... }

--
[ e d @ h a l l e y . c c ]