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 Ela on May 5, 2008, 9:44 pm
Please log in for more thread options
Dear all,

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$/

Unfortunately the error message does not tell me which line of which file
leads to the problem. Could anybody advise?



Posted by Ben Bullock on May 5, 2008, 10:07 pm
Please log in for more thread options
On Tue, 06 May 2008 09:44:32 +0800, Ela wrote:

> 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$/
>
> Unfortunately the error message does not tell me which line of which
> file leads to the problem. Could anybody advise?

Just grep for oxoacyl?

In Perl you can do it like this:

cat *.pl | perl -n -e 'print "$.:$_" if /oxoacyl/;'

But are you sure there are no line numbers?

#!/usr/local/bin/perl
print if /[z-a]/;

Invalid [] range "z-a" in regex; marked by <-- HERE in m/[z-a <-- HERE ]/
at ./usenet-2008-5-6-c.pl line 2.

I got the line number at the end there.



Posted by Ronny on May 7, 2008, 7:21 am
Please log in for more thread options
> On Tue, 06 May 2008 09:44:32 +0800, Ela wrote:
> > 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$/
>
> > Unfortunately the error message does not tell me which line of which
> > file leads to the problem. Could anybody advise?
>
> Just grep for oxoacyl?

This might not help here, unless the regexp is really given literally
(in which case the OP likely would have found it already). I suspect
that there is a string interpolation going on - kind of

m/^$$/

In this case, a simple source code search wouldn't be of much help.

Ronald

Posted by Ben Bullock on May 7, 2008, 10:25 am
Please log in for more thread options
> On 6 Mai, 04:07, Ben Bullock
> > Just grep for oxoacyl?
>
> This might not help here, unless the regexp is really given literally
> (in which case the OP likely would have found it already). I suspect
> that there is a string interpolation going on - kind of
>
> m/^$$/

It's possible, but I don't see the point in speculating without
further information from the original poster. Note that, as I pointed
out in the part of the message you didn't quote, the original poster
claimed he wasn't getting line numbers in the error messages, which
isn't the behaviour of Perl 5.8 or Perl 5.10, or probably any other
version of Perl you could find, so until that is clarified there is
not much else to say about it. Realistically the most likely
explanation is that he somehow missed the line numbers in Perl's error
message.

Posted by Frank Seitz on May 7, 2008, 10:39 am
Please log in for more thread options
Ben Bullock wrote:
>
>>On 6 Mai, 04:07, Ben Bullock
>>
>>>Just grep for oxoacyl?
>>
>>This might not help here, unless the regexp is really given literally
>>(in which case the OP likely would have found it already). I suspect
>>that there is a string interpolation going on - kind of
>>
>> m/^$$/
>
> It's possible, but I don't see the point in speculating without
> further information from the original poster. Note that, as I pointed
> out in the part of the message you didn't quote, the original poster
> claimed he wasn't getting line numbers in the error messages, which
> isn't the behaviour of Perl 5.8 or Perl 5.10, or probably any other
> version of Perl you could find, so until that is clarified there is
> not much else to say about it. Realistically the most likely
> explanation is that he somehow missed the line numbers in Perl's error
> message.

The OP expected, strangely enough, the line number
of the input file, not the line number of the source file.

Frank
--
Dipl.-Inform. Frank Seitz; http://www.fseitz.de/
Anwendungen für Ihr Internet und Intranet
Tel: 04103/180301; Fax: -02; Industriestr. 31, 22880 Wedel

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