http://www.perlmonks.org?node_id=537834


in reply to Reading from another file.

#! /usr/bin/env perl use strict; use warnings; use File::Slurp qw/slurp/; # I am a unix filter! die "usage: <pattern> <file>\n" unless @ARGV == 2; my $p = $ARGV[0]; my $fc = slurp $ARGV[1]; while (defined($_ = <STDIN>)) { s/\Q$p/$fc/; print }