Z. M. Wu wrote:
> Perl does not like if $other contains special characters
> like * ] in the following
>
> my @a=split/$other/,$req;
No, they are special characters in regular expressions, and need to be
escaped.
> My current workaround is
>
> $other=~ s/[\)\(\*]/_/g;
> $req=~ s/[\)\(\*]/_/g;
>
> before the split.
>
> Any insight or better solution would be helpful
Better solution:
my @a = split /\Q$other/, $req;
See "perldoc perlre".
--
Gunnar Hjalmarsson
Email:
http://www.gunnar.cc/cgi-bin/contact.pl