in reply to Re3: Code rot?
in thread Code rot?

FWIW, here's the whole beginning of my script:
#!/usr/bin/perl -w use warnings; use CGI qw(:standard *table); # Location of screen/field description file $screenflddescpath = "descriptions.txt"; open SCREENFLDDESC, $screenflddescpath or die "cannot find screen description file: $!"; while (<SCREENFLDDESC>) { chomp; ($key, $desc) = split /,/; $screenflddesc{$key} = $desc; } close SCREENFLDDESC; # Location of index file we will write results to $indexfile = ">screenindex.html"; open INDEX, $indexfile or die "cannot open index for writing: $!"; # Location of master GUI file # $guipath = "Master.gui"; $guipath = "Master.gui.test"; open GUIFILE, $guipath or die "cannot find Master.gui: $!"; # Start our index file print INDEX start_html("GUI Map Index"), "\n"; print INDEX h1("GUI Map Index"), "\n"; print INDEX "Click on a screen name below to go to its description pag +e", br, "\n"; print INDEX hr, "\n"; # Flag to let us know if we're inside a description block $desc = 0; # Current file name $currfile = ""; while (<GUIFILE>) { chomp; # print "Line: $_\n"; # Outside description block with no ".": Screen name # (or quoted name without following ".") # (Regex was originally /^([^.]+):$/) if ($desc != 0 and /^(\w+):$/) { # this is where the warning is pr +inted print "Screen name: $1\n"; # etc...
There's nothing fancy going on here. Regexes have not changed between 5.6.1 and 5.8.0. I'm not doing anything to $_ except a chomp. I ran the line you had above, and reported that the syntax is OK after printing the parsed version of my script (which didn't change the script noticeably). Does anybody know if Perl has somehow been broken on the new version of Cygwin? edit: Of course, I mean that the regex functions I'm using have not changed btwn 5.6.1 and 5.8.0 - I'm sure there have been other unrelated changes.

Replies are listed 'Best First'.
Re5: Code rot?
by dragonchild (Archbishop) on Sep 23, 2003 at 01:05 UTC
    Well, first off, I'm going to tell you to use strict. I noticed one place that makes maintenance hard (your dual use of $desc). Your code is almost strict as it is. Take the final step.

    Secondly, are you sure that your line actually has stuff in it? Uncomment the print and see if it complains about an undefined variable being used ...

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

Re: Re: Re3: Code rot?
by Beechbone (Friar) on Sep 23, 2003 at 11:13 UTC
    Please also post all the elsif() lines to that if(). I'd think there must be one, because there is no string concatanation in the if().

    BTW: Warnings in elsif() conditions are reported with the line number of the if(). Nice to know...

      Dragonchild: To your 2 points, I have now changed the script so that it passes use strict - still getting warnings. I have also ensured that the lines are coming back with data in it (105 lines in my test file, and I get 105 warnings).

      Beechbone: Here are all the elsifs:

      if (!$desc and /^(\w+):$/) { # ... } elsif (/^\{$/) { # ... } elsif (/^\}$/) { # ... } elsif (!$desc and /^"?$screen"?\.(.+):/) { # ... } elsif ($desc and /^\s*id:\s*(\d+)$/) { # ... } else { # ... }
      As you can see, no concatenations in the elsifs, just a bunch of regexes. If you'd like, I can post the whole script, but I'll wait till someone says they want it. Thanks.
        Here is the concatenation:
        } elsif (!$desc and /^"?$screen"?\.(.+):/) {
        $screen is concatenated with the rest of the regex. I'd bet it was undef...
        Well well well. It seems running this script using the latest ActivePerl binary works just fine! There must be something broken with Cygwin's Perl... I'll take this up with the Cygwin people. Thanks anyway.

        EDIT: The problem was solved because Cygwin's perl was expecting Unix linefeeds, and my source file uses Windows CRLF. I was told that setting the environment variable

        export PERLIO=crlf
        solves this problem, and it did nicely. I'm also told, though, that it's a bit buggy, but in this case, it solves the mysterious difference between Cygwin Perl and ActivePerl. Cheers!