#!/usr/bin/perl use strict; use warnings; # 800208 my $test; while ( ) { $test = $_; if ( $test =~ /#1 aba baba/ ) { chomp $test; print "$test Cheers\n"; } else { print "$test"; } } __DATA__ #1 aba baba #1 bsdb dbbsd #1 sdh hsds #1 aba baba #2 aba baba