$post_message =~ s/\Q[[$1]]/[[$article_id]]/sig; #### while ($input =~ /\G(.*?)\[\[([^]]+)\]\]/sg) { my $link = $2; $output .= $1; $output .= process($link); } #### $post_message =~ s{\[\[([^]]+)\]\]}{ process($1) }esg;