$aXML =~ s@@gs; $aXML =~ s@{bs}@/@gs; $aXML =~ s@{colon}@:@gs; $aXML =~ s@{semicolon}@;@gs; ... while ($aXML =~ m@<([^<>]+?)>(.*?)@gs) { ... } ... while ($aXML =~ m@\[([^\[\]]*?)\]@gs) { ... } #### my @chars = split //, $aXML; ... foreach my $char (@chars) { ... }