#!/usr/bin/perl -w use strict; use Regexp::Common; my $teststring= "teststring: start hello {ab}{cd} end\n"; my $balancedparens= qr/\s*$RE{balanced}{-parens=>'{ }'}/; my $pattern1= $balancedparens . $balancedparens; my $pattern2= qr/hello/; my $pattern3= $pattern2.$pattern1; print "no error yet\n"; $teststring=~ s/$pattern3/hi$1/g; ## ERROR, WHY??? print $teststring;