#!/usr/bin/perl -w use strict; open INPUT, 'your_input_fiel.txt'; open OUTPUT '>your_output_file.txt'; while (my $line = ) { chomp $line; $line =~ s/hello/goodbye/gi' print $line; } close INPUT; close OUTPUT;