Wassercrats has asked for the wisdom of the Perl Monks concerning the following question:
Read the comments. Don't ask me to explain what the code does. I know what it used to do before I chiseled away at it in a failed attempt to isolate the bug (in Perl, I assume), and that is proprietary information.
The only thing I know is that the output makes sense if you change $Build_Text .= $New_Line.'<br>';(near the bottom) to $Build_Text .= $New_Line;
#!/usr/bin/perl -w ###################################################################### +######## print "Content-type: text/html\n\n"; $Count_Link = 14; @line = ('<a href = "http://polisource.com">12(2345678901234)</a>'); for($Link_Count=0;$Link_Count<scalar(@line);$Link_Count++) { $line[$Link_Count] =~ /href.+?>(.*?)</; $Text = $1; if(length($Text) <= $Count_Link) { $line[$Link_Count] =~s /(href.+?>)(.*?<)/$1$Build_Text$2/; $Build_Text = ""; next; } $Width2 = $Count_Link-1; $Order = substr($Text,0,$Count_Link); if($Order !~ /\(/) { $Build_Text .= $Order . '<br>'; $line[$Link_Count] =~s /(href.+?>)\Q$Order\E/$1/; $Link_Count--; if (substr ($Text,$Count_Link,1) ne ' ') { if (!$Links_Count) { chomp($ORIGINAL_DOC = "$OriginalLinks[$OL_count]"); $Links_Count .= " $ORIGINAL_DOC:\n"; } $Links_Count .= "$Order"; next; } } for($Break_Count = $Width2;$Break_Count>-1;$Break_Count--) { $character = substr($Order,$Break_Count,1); $c2 = ')'; if ($character eq '[') { $c2 = ']'; } ################################### ### "test 1" gets printed. if (!$Break_Count){ print "<br>test 1"; } ################################### if ((!$Break_Count)&& ($Build_Text =~ /.*?(?!<br>.*<br>)(.*)(<br>)/)&& (length $1 < $Count_Link)&& ($line[$Link_Count] =~ /href.+?>$Order($c2|.$c2)/)) { ###################################################### ### If the above condition were true, "test 2" would be printed. Since + it's not printed, this block is skipped. if (!$Break_Count){ print "<br>test 2"; } ###################################################### $New_Line = substr($Order,1); $line[$Link_Count] =~s /(href.+?>).{$Count_Link}(.)/$1/ +; $Build_Text =~s /<br>$/$character<br>$New_Line$2<br>/; $Link_Count--; last; } elsif (!$Break_Count) { ################################### ### Nothing changed since "test 1" ### was printed, so why isn't ### "test 3" printed? if (!$Break_Count){ print "<br>test 3"; } ################################### $Build_Text .= $Order . '<br>'; $line[$Link_Count] =~s /(href.+?>)\Q$Order\E/$1/; $Link_Count--; last; } elsif ($character eq '(') { $New_Line = substr($Order,0,$Break_Count); $Build_Text .= $New_Line.'<br>'; $line[$Link_Count] =~s /(href.+?>)\Q$New_Line\E/$1/is; $Link_Count--; last; } } }
update (broquaint): title change (was Why?)
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Strange problems with CGI script
by BrowserUk (Patriarch) on Jan 28, 2003 at 08:58 UTC | |
by Wassercrats (Initiate) on Jan 28, 2003 at 09:23 UTC | |
by PodMaster (Abbot) on Jan 28, 2003 at 09:35 UTC | |
by Wassercrats (Initiate) on Jan 28, 2003 at 10:00 UTC | |
Re: Strange problems with CGI script
by PodMaster (Abbot) on Jan 28, 2003 at 09:29 UTC | |
by Wassercrats (Initiate) on Jan 28, 2003 at 09:47 UTC |
Back to
Seekers of Perl Wisdom