if( m/<([^>]*meta-parameter[^>]*stored-procedure[^>]*)>/ ) { my $tag = $1; if( $tag =~ m/id=['"](.+?)['"]/ ) { my $id = $1; # argueably not the most robust thing in the whole wide world, # but you get the idea } }