Identification of which line causing regex problem

Discussion in 'Perl Misc' started by Ela, May 6, 2008.

  1. Ela

    Ela Guest

    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?
     
    Ela, May 6, 2008
    #1
    1. Advertising

  2. Ela

    Ben Bullock Guest

    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.
     
    Ben Bullock, May 6, 2008
    #2
    1. Advertising

  3. Ela

    Ronny Guest

    On 6 Mai, 04:07, Ben Bullock <> wrote:
    > 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/^${protein_name}$/

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

    Ronald
     
    Ronny, May 7, 2008
    #3
  4. Ela

    Ben Bullock Guest

    On May 7, 8:21 pm, Ronny <> 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/^${protein_name}$/


    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.
     
    Ben Bullock, May 7, 2008
    #4
  5. Ela

    Dr.Ruud Guest

    Ela schreef:

    > 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?


    This is not a runnable and minimal source. Go and read the Posting
    Guidelines again.

    --
    Affijn, Ruud

    "Gewoon is een tijger."
     
    Dr.Ruud, May 7, 2008
    #5
  6. "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$/


    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
     
    Jürgen Exner, May 7, 2008
    #6
  7. On 2008-05-07 14:32, Dr.Ruud <> wrote:
    > Ela schreef:
    >> 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?

    >
    > This is not a runnable and minimal source.


    What would "runnable and minimal source" be in this case?

    > Go and read the Posting Guidelines again.


    Go and read the question before answering.

    hp
     
    Peter J. Holzer, May 9, 2008
    #7
  8. On 2008-05-07 14:39, Frank Seitz <> wrote:
    > Ben Bullock wrote:
    >> 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.


    Why do you think so?

    hp
     
    Peter J. Holzer, May 9, 2008
    #8
  9. Ela

    Dr.Ruud Guest

    Peter J. Holzer schreef:

    > Go and read the question before answering.


    *plonk*

    --
    Affijn, Ruud

    "Gewoon is een tijger."
     
    Dr.Ruud, May 9, 2008
    #9
  10. Ela

    Guest

    Jürgen Exner <> wrote:
    > "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$/

    >
    > 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.
     
    , May 9, 2008
    #10
  11. Ela

    Gordon Etly Guest

    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
     
    Gordon Etly, May 9, 2008
    #11
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sorin Sandu

    Client identification

    Sorin Sandu, Apr 9, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    386
    Guest
    Apr 9, 2004
  2. Sorin Sandu

    Re: Client identification

    Sorin Sandu, Apr 9, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    345
    Bruno Sirianni
    Apr 9, 2004
  3. news.frontiernet.net
    Replies:
    3
    Views:
    10,443
    Barry Pearson
    Apr 18, 2004
  4. Replies:
    3
    Views:
    768
    Reedick, Andrew
    Jul 1, 2008
  5. Oltmans
    Replies:
    2
    Views:
    257
Loading...

Share This Page