in reply to How to handle both a STDIN pipe and file from command line?

If you're going for the minimum in terseness; you can always use a temporary file:

./print_list >/temp/temp.txt; perl temp.txt file.txt; rm temp.txt would read from the first file, then use the contents to substitute in the second file:

use strict; use warnings; open(my $file1, '<', $ARGV[0]) or die "Can't open $ARGV[0]: $!\n"; my @substitutions = <$file1>; close($file1); chomp(@substitutions); open(my $file2, '<', $ARGV[1]) or die "Can't open $ARGV[1]: $!\n"; while(my $line = <$file2>) { for my $replace (@substitutions) { next unless $replace; # skip blanks $line =~ s/\Q$replace\E/foo/g; } print $line; } close($file2);