#!/bin/perl -w use strict; my $string="hello code goes here "; $string=~ s{(.*?)}{replace( $1)}egs; print $string; sub replace { my $text_in_tag= shift; $text_in_tag=~ s{\n}{}g; return $text_in_tag; }