Hi Rajesh, On Thu, 19 Sep 2013 23:39:48 +0530 rajesh kumar <rajeshkr...@gmail.com> 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); Using string eval like that is usually not such a good idea, so I hope the evaled code is not user-editable. You can achieve a similar effect somewhat more safely by interpolating strings into qr/.../ Like: [CODE] my $re_s = 'a.*?b'; my $re = qr/$re_s/; [/CODE] > > 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/ > ]; > This is expected due to Perl's internal representation of the regular expressions objects. Both the above and below do the same thing. Regards, Shlomi Fish > Please help. > > Thanks, > Rajesh -- ----------------------------------------------------------------- Shlomi Fish http://www.shlomifish.org/ http://www.shlomifish.org/humour/Summerschool-at-the-NSA/ SGlau: I suppose serving here at the NSA is also one of your 99 problems? Daniel: Hey, this place is at least ninety of my problems. — http://www.shlomifish.org/humour/Summerschool-at-the-NSA/ Please reply to list if it's a mailing list post - http://shlom.in/reply . -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/