aarestad has asked for the wisdom of the Perl Monks concerning the following question:

So I wrote a Perl script about 5 months ago to parse a rather strange text file. Here's a sample of the source file:
AACE_1: { class: mic_if_win, label: "!AACE.*", mic_if_handles_windows: 1 } { rtree_state: close, ltree_state: close } AACE_1."ADDR LINE1": { class: field, id: 734 }
etc. (For those who may recognize it, it's a GUI Map file used by WinRunner, an automated testing suite.) Each header of a braced chunk is either a screen (green-scren) name or field name - the field names have the screen name they're on, followed by ".", followed by the field name. To determine whether I'm on a line that contains a screen name, I use this line:
if ($desc != 0 and /^([^.]+):$/) { # do stuff }
Looking at that regex now, I think, it'd be smarter to use
/^(\w+):$/
but that's not the issue. Both the original regex and the one I have above produce this warning for each and every line of input:
Use of uninitialized value in concatenation (.) or string at ./genguim +apdoc.pl line 52, <GUIFILE> line n.
WTF? This script worked perfectly 5 months ago. The input file has not changed, nor has the script. Is there something fundamentally wrong with the regex?

Replies are listed 'Best First'.
Re: Code rot?
by dragonchild (Archbishop) on Sep 22, 2003 at 19:52 UTC
    You upgraded from Perl 5.00x to Perl 5.6.x or 5.8.x, right?

    ------
    We are the carpenters and bricklayers of the Information Age.

    The idea is a little like C++ templates, except not quite so brain-meltingly complicated. -- TheDamian, Exegesis 6

    Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.

      You betcha - I'm currently using 5.8.0 for the latest Cygwin (1.5.5-cr-0x9b), and back then I was using, if not 5.8.0, then 5.6.1, also for Cygwin.
        Hence, something changed. You need to tell us these things!

        There is no code that is guaranteed to work between Perl versions. You may have to tweak it a little. I would suggest using perl -MO=Deparse scriptname.pl to find out what it's doing. The problem isn't in the if-condition. It's earlier on, where $_ is set.

        ------
        We are the carpenters and bricklayers of the Information Age.

        The idea is a little like C++ templates, except not quite so brain-meltingly complicated. -- TheDamian, Exegesis 6

        Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.