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

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.

Replies are listed 'Best First'.
Re: Re3: Code rot?
by aarestad (Sexton) on Sep 22, 2003 at 21:37 UTC
    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.
      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.

      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.