use strict; use warnings; my @all_lines = ; # get the lines that match the word 'number' my @lines = grep /number/, @all_lines; print "Lines that matched\n"; print for @lines; # get and highlight the lines that match the word 'number' my @bold = map { $_ =~ /number/ and s/number/number<\/b>/g ? $_ : (); } @all_lines; print "\nHighlighted word\n"; print for @bold; __DATA__ number.................... ..................... ......number.............. ......................... ..................number