> 2012/7/12 timothy adigun <2teezp...@gmail.com> > >> Hi xiyoulaoyuanjia, >> Check my comments below. >> >> On 7/12/12, xiyoulaoyuanjia <xiyoulaoyuan...@gmail.com> wrote: >> > i am very sorry ! i am intend to parse variable $a by the regular >> > variable $b . in below way! >> >> the below script will not give any output. >> > ---------------------------------------- >> > $a="abc[0]"; >> > $b="bc[0]"; >> > $a=~/$b/; >> > --------------------------------------------- >> even if you decide to use: >> >> print $a if $a=~m/$b/; #no output >> >> > but it can not parse right ! just because the "[" symbol。 i kow >> > $a=~/abc\[0]/ it can get right! >> > but when regular is a varible . I do not know how to solve it? >> >> to get what you wanted you will do might do this: >> >> $a="abc[0]"; >> $b="bc[0]"; >> print $a if $a=~m/\Q$b\E/; # prints abc[0] >> >> NOTE: >> Please take note of the \Q and \E in the REs. >> Don't use variable $a and $b, since these are default for sort >> function. You will observe that without declaring these variables you >> have your intended output (I suppose). >> Others will say use strict and warnings pragma in your scripts, >> however few the lines of codes. >> >> >> > Sorry if this isn't clear let me know if there are any questions. >> > thanks in advance! >> > >> > >> > 2012/7/12 Jack Maney <jma...@adknowledge.com> >> > >> >> I don't understand what you're trying to say or do. Exactly what error >> >> message are you getting? >> >> >> >> -----Original Message----- >> >> From: xiyoulaoyuanjia [mailto:xiyoulaoyuan...@gmail.com] >> >> Sent: Wednesday, July 11, 2012 10:54 PM >> >> To: beginners@perl.org >> >> Subject: regular error >> >> >> >> *hi all:* >> >> * i have an error in below * regular >> >> ---------------------------------------- >> >> $a="abc[0]"; >> >> $b="bc[0]"; >> >> $a=~/$b/; >> >> --------------------------------------------- >> >> how can i do in this way? >> >> thanks ! >> >> -- >> >> 继续上路。。 >> >> you can follow me at twitter >> >> @xiyoulaoyuanjia >> >> >> > >> > >> > >> > -- >> > 继续上路。。 >> > you can follow me at twitter >> > @xiyoulaoyuanjia >> > >> >> >> -- >> Tim >> > > > > -- > 继续上路。。 > you can follow me at twitter > @xiyoulaoyuanjia > >
-- 继续上路。。 you can follow me at twitter @xiyoulaoyuanjia