my @files_to_do; if ( @ARGV and -f $ARGV[0] ) @files_to_do = @ARGV; } else { print "Enter file name(s), separated by space and/or newline:\n" if ( -t ); while () { chomp; push @files_to_do, split //; } } die "Nothing to do\n" unless @files_to_do; # now do something that loops over @files_to_do... #### ls | my_backup.pl find some_path -name '*.foo' | my_backup.pl