use strict; use warnings; my $text; { local $/; $text = ; } $text =~ s/\#\#\#\n\[b\](.+)\[\/b\]/$1<\/TAG>/g; print $text; __DATA__ ### [b]word[/b] text ###