#! perl -sw use strict; while( ) { s[^(<([^>]+?)>)(.*)()]{ (my $x = $3) =~ tr[<>][[]]; "$1$x$4"; }e; print; } __DATA__ my data here further text not good as contains in angle brackets another possibility is one in here and content containing a false and a real #### C:\Perl\test>junk2 my data here further text not good as contains [this] in angle brackets another possibility is [more] [than] one [angle pairs] in here and content containing a false [/a tag with spaces] and a real