On 19/09/2013 20:09, rajesh kumar wrote:
Hi,
I am reading a set of regex, separated by comma, from database, which is
in string format and using eval to convert them in the array.
For e.g.,
String from database is'qr/^abc .* $/,qr/xxx/'
$string = 'qr/^abc .*$/,qr/xxx/'; # this $string comes from DB
$string = '[' . $string . ']';
my @cleaners = eval($string);
When I print using Data::Dumper, the output looks like
$VAR1 = [
qr/(?-xism:^abc .*$)/,
qr/(?-xism:xxx)/
];
but i want it like
$VAR1 = [
qr/^abc .*$/,
qr/xxx/
];
It looks to me like you worry for nothing, these qr-expressions mean the
same.
I would worry about the string-eval, so I would parse a bit deeper, and
use something like:
while ( $parsed = $data->next() ) {
eval { $regex = qr/$parsed/ ;1 }
or die "ERROR: /$parsed/ is bad";
push @regexen, $regex;
}
--
Ruud
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/