On Sun, Apr 29, 2012 at 11:26 PM, Lawrence Statton <lawre...@cluon.com> wrote: > On 04/29/2012 10:21 AM, lina wrote: >> >> Hi, >> >> I have a text file like: >> >> $ more sample.tex >> >> aaa \cite{d1,d2},ddd \cite{e1},ccc \cite{f1,f2,f3} >> bbb\cite{inhibitor}aaa >> >> >> sub read_tex{ >> open my $fh, '<', @_; >> while(<$fh>){ >> if(/cite\{(.+?)\}/){ >> push @citeditems,split/,/,$1; >> } >> } >> close($fh); >> } >> >> It only extract the first \cite part out, failed to extract the e1, >> f1, f2, f3 and uncertain number of being cited item out. >> >> Can someone give me some suggest regarding how to upgrade the match part? >> >> Thanks with best regards, >> > > Your regexp only asks for a single \cite... match in each line. > > perldoc perlretut > > Search for "Global Matching" roughly half-way down the page.
if($_ =~ m/cite\{(.+?)\}/g){ Not work. Do I need to use backreference to handle the uncertain number of following cite match? Thanks for your quick reply. Best regards, > > -- > To unsubscribe, e-mail: beginners-unsubscr...@perl.org > For additional commands, e-mail: beginners-h...@perl.org > http://learn.perl.org/ > > -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/