while ($data_in =~ /(.+?)<\/a>(.+?)<\/b><\/container>(<\?query\?>)??/ig) { { no warnings 'uninitialized'; $data_out = "$2, $1$3 "; } # further processing }