in reply to Want a faster replace, Please

Is this any better?
#!/usr/bin/perl use strict; use warnings; my @AUBBC_TAGS = ( 'b', 'i', 'sub', 'sup', 'pre', 'ul', 'ol', 'small', 'big', 'li', 'p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'div', 'strong' ); my $message = '[b] stuff [i] stuff [/i] [/b]'; foreach (@AUBBC_TAGS) { $message =~ s/\[(.?)?$_\]/<$1$_>/gx; } print $message, "\n";

Replies are listed 'Best First'.
Re^2: Want a faster replace, Please
by JavaFan (Canon) on Sep 12, 2010 at 18:14 UTC
    I've looked really hard, but what it the difference between your suggestion and the code the OP posted?