Click here to get back home

Identification of which line causing regex problem

 HomeNewsGroups | Search | About
 comp.lang.perl.misc    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Identification of which line causing regex problem Ela 05-05-2008
Posted by Gordon Etly on May 9, 2008, 12:55 pm
Please log in for more thread options
Dr.Ruud wrote:
> Peter J. Holzer schreef:
>
> > Go and read the question before answering.
>
> *plonk*

Yes, the whole world really needs to know you added someone to your
killfile...

--
G.Etly



Posted by Jürgen Exner on May 7, 2008, 11:24 am
Please log in for more thread options
>I'm modifying a system (totally more than 100000-lines for tens of files)
>written by others and would like to identify which line leads to the
>following problem.
>
>Invalid [] range "l-c" in regex; marked by <-- HERE in m/^3-oxoacyl-[acyl-c
><-- HERE arrier protein] reductase fabg1$/

Well, the character set
        [acyl-carrier protein]
does contain the range 'l-c' which is empty. Obviously that is what perl
is complaining about. Solution: just escape the dash with a leading
backslash.
However, I doubt that will produce the effect you are looking for. Are
you really, really sure you want that character set there? To me it
looks much more like you want a literal match of the text 'acyl-carrier
protein'.

>Unfortunately the error message does not tell me which line of which file
>leads to the problem.

First I didn't believe you but a quick test confirms that you are right.
The perl interpreter does not print a file/line information (tried it on
5.6.1). Wierd!

>Could anybody advise?

Just grep your files for the offending m/// instruction. Something
similar to         
        grep "acyl-carrier protein" *.pl

jue





Posted by xhoster on May 9, 2008, 12:32 pm
Please log in for more thread options
> >I'm modifying a system (totally more than 100000-lines for tens of
> >files) written by others and would like to identify which line leads to
> >the following problem.
> >
> >Invalid [] range "l-c" in regex; marked by <-- HERE in
> >m/^3-oxoacyl-[acyl-c <-- HERE arrier protein] reductase fabg1$/
>
> Well, the character set
> [acyl-carrier protein]
> does contain the range 'l-c' which is empty. Obviously that is what perl
> is complaining about. Solution: just escape the dash with a leading
> backslash.
> However, I doubt that will produce the effect you are looking for. Are
> you really, really sure you want that character set there? To me it
> looks much more like you want a literal match of the text 'acyl-carrier
> protein'.

I think it is much more likely that the string is coming from a data file
and put into the regex via a variable, not hard-coded into the script.

Going further out on a limb, he probably should use index rather than
a regex once he tracks down where the regex is.

>
> >Unfortunately the error message does not tell me which line of which
> >file leads to the problem.
>
> First I didn't believe you but a quick test confirms that you are right.
> The perl interpreter does not print a file/line information (tried it on
> 5.6.1). Wierd!

Yes indeed. I had to dig up a copy of 5.6.1 just to see it for myself.
So one obvious tip to the OP would be to upgrade to a newer perl,
preferably for production or at least just for debugging. (I didn't see
this documented in the Changes* files, so I don't know when the code was
fixed.)


>
> >Could anybody advise?
>
> Just grep your files for the offending m/// instruction. Something
> similar to
> grep "acyl-carrier protein" *.pl

Probably have to grep all the data files, too.

Xho

--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.

Similar ThreadsPosted
Multiple regex on one line June 6, 2005, 10:38 am
Multi Line Match and Regex November 27, 2006, 10:08 pm
Regex matching a integer in a line February 21, 2007, 1:54 am
using regex to select line matches June 15, 2007, 4:21 pm
quote causing DBD::CSV failure February 28, 2006, 6:42 pm
multiple regex pattern matching per line? September 4, 2004, 2:24 pm
Insert Text on line after regex match April 10, 2005, 8:01 pm
Win32::OLE MS Word line breaks regex February 3, 2007, 6:43 pm
Regex for "at start of line OR preceded by space". April 27, 2008, 2:17 am
$str1 eq $str2 causing problems August 22, 2005, 12:11 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap