use Regexp::Common qw(balanced); if ($foo =~ / ( $RE{balanced} ) /x) { print "grabbed $1"; } #### $"=$,,$_=q>|\p4<6 8p .q>.<4-KI;$, .=pack'N*',"@{[unpack'C*',$_] }"for split/