Re: Cookies.pm netscape cookie format help

Gisle Aas (gisle@aas.no)
09 Jun 1999 20:10:51 +0200


Russell Locke <rlocke@hbs.edu> writes:

> How I found out that the entire file is being read in as one line....

It looks like HTTP::Cookies could use this patch:

Index: lib/HTTP/Cookies.pm
===================================================================
RCS file: /home/cvs/aas/perl/mods/libwww-perl/lib/HTTP/Cookies.pm,v
retrieving revision 1.10
diff -u -u -r1.10 Cookies.pm
--- Cookies.pm	1999/03/20 07:37:35	1.10
+++ Cookies.pm	1999/06/09 18:02:27
@@ -485,6 +485,7 @@
     my $self = shift;
     my $file = shift || $self->{'file'} || return;
     local(*FILE, $_);
+    local $/ = "\n";  # make sure we got standard record separator
     open(FILE, $file) or return;
     my $magic = <FILE>;
     unless ($magic =~ /^\#LWP-Cookies-(\d+\.\d+)/) {
@@ -691,6 +692,7 @@
     my($self, $file) = @_;
     $file ||= $self->{'file'} || return;
     local(*FILE, $_);
+    local $/ = "\n";  # make we got standard record separator
     my @cookies;
     open(FILE, $file) || return;
     my $magic = <FILE>;

I really hate these kind of bugs.  Perl should somehow have treated
these variables like it now does for $[.  I wonder how many modules
use print without making sure $, and $\ have their standard values
first.

Regards,
Gisle