From: Nicholas C. <ni...@cc...> - 2002-11-13 09:42:19
|
On Wed, Nov 13, 2002 at 09:24:54AM +0000, Nick Cleaton wrote: > The right way to get correct header line endings for the platform is with > CGI.pm's header() function, but older versions of CGI.pm don't support the > -charset option to header(), so we can't just put: > > print header('-type'=>'text/html', '-charset'=>$charset); > > and have it work back to 5.00404. I've tested > > print header('-type' => "text/html; charset=$charset"); > > in both 5.00404 and 5.008, and it works without warnings. > > I propose that we change any scripts that roll their own CGI headers over > to this second way of doing it, and hope no future version of CGI.pm adds > a warning for this type of abuse of -type. > > Thoughts ? We're trying to suggest best practice, aren't we? I'd feel happier with something longer, such as if ($] >= 5.005) { # This is the correct way to set the charset print header('-type'=>'text/html', '-charset'=>$charset); } else { # However the CGI.pm supplied with perl before 5.005 doesn't have the # -charset option so we cheat: print header('-type' => "text/html; charset=$charset"); } Is there actually an explanation tutorial that goes with the code? Or do all the design decisions rest in the fading memories of the contributors? Presumably inline design decisions in =pod could be cut out automatically by whatever is rolling the distribution up from the CVS version. (if this feature is wanted) Nicholas Clark |