in reply to DBI, s/// => unitinitialized value in substitution
I suggest that you re-code the statement to remove all doubt ... to eliminate any possible uncertainty about what those square-brackets might mean.
my $foo = $rex[0]; my $bar = $rex[1]; s/$foo/$bar/ig;
Realistically, it won't make any difference to the Perl compiler, and now “the designer's intentions are made clear.”