my $search = "this"; my $data = "This is the test text for THIS routine."; my $bs = ""; my $be = ""; my $count = $data =~ s/\b($search)\b/$bs\1$be/gi;