From nobody@hyperreal.com Thu Jun 26 00:22:52 1997 Received: (from nobody@localhost) by hyperreal.com (8.8.5/8.8.5) id AAA21892; Thu, 26 Jun 1997 00:22:52 -0700 (PDT) Message-Id: <199706260722.AAA21892@hyperreal.com> Date: Thu, 26 Jun 1997 00:22:52 -0700 (PDT) From: Dion Almaer Reply-To: dion@member.com To: apbugs@hyperreal.com Subject: Bad Perl Code is mentioned in the FAQ, #31 X-Send-Pr-Version: 3.2 >Number: 789 >Category: documentation >Synopsis: Bad Perl Code is mentioned in the FAQ, #31 >Confidential: no >Severity: non-critical >Priority: medium >Responsible: apache >State: closed >Class: doc-bug >Submitter-Id: apache >Arrival-Date: Thu Jun 26 00:30:01 1997 >Last-Modified: Thu Jun 26 02:23:08 PDT 1997 >Originator: dion@member.com >Organization: >Release: 1.2b8 >Environment: All... it's in documentation >Description: The perl code example in #31 of the Apache FAQ is flawed in 3 ways. a) the regex is wrong as it allows /foonph-cgi (due to the /*). b) printf is not needed. print should be used. c) no semi colon should be after the if statement. see the way to fix it. >How-To-Repeat: 31.How can I get my script's output without Apache buffering it in the FAQ >Fix: the perl code is now: if ($0 =~ m:/*nph-:) { $HTTP_headers = "HTTP/1.1 200 OK\015\012"; $HTTP_headers .= "Connection: close\015\012"; printf ($HTTP_headers); }; and it should a) the regex is wrong as it allows /foonph-cgi (due to the /*). b) printf is not needed. print should be used. c) no semi colon should be after the if statement. if ($0 =~ m:/nph-:) { $HTTP_headers = "HTTP/1.1 200 OK\015\012"; $HTTP_headers .= "Connection: close\015\012"; print $HTTP_headers; } >Audit-Trail: State-Changed-From-To: open-closed State-Changed-By: coar State-Changed-When: Thu Jun 26 02:23:08 PDT 1997 State-Changed-Why: >Unformatted: >a) the regex is wrong as it allows /foonph-cgi (due to the /*). Right you are, though the correct RE is m:^/*nph-:. Fixed. >b) printf is not needed. print should be used. Using printf is not an error, but you're right - print is definitely better here. Fixed. >c) no semi colon should be after the if statement. This isn't an error, either, but essentially the same reasoning applies. Fixed. These changes will appear on the web site shortly, and will be in the documentation included in the next release. Thank you for pointing this out, and for using Apache!