##
ls *.txt | my_script.pl
####
my_script.pl text.txt
####
#!/usr/bin/perl
use strict;
use warnings;
my @files;
if ( @ARGV ) {
@files = map { -f $_ ? $_ : () } @ARGV;
}
else {
while ( <> ) {
chomp;
push @files, $_;
}
}