Re: Cookies.pm netscape cookie format help
Russell Locke (rlocke@hbs.edu)
Wed, 9 Jun 1999 10:19:21 -0400
Answer to both of your questions.....
>How did you determine that it is reading it as one line?
>Try setting $/ to \n before calling new...
In Cookies::Netscape->load
my $magic = <FILE>;
is supposed to read in the first line to test the file to be a netscape
formatted cookie file. It checks for the first line of the file to contain
a comment line of "# Netscape HTTP Cookie File". If this is not found then
the file is not a netscape formatted cookie file and the process is dumped.
How I found out that the entire file is being read in as one line.... I
simply added a line of code to Cookie.pm following the read, that did
printf STDERR "Cookie line 1 =\"" / $magic . "\"";
The output I got was the contents of the entire file. Never mind that when
the code reaches the while loop
while (<FILE>)
the loop is never entered... therefore there must be nothing left in the
read buffer. I've also verified this by writing out $magic to a file, same
results.
>
>> I commented out the Netscape Cookie.txt header check code and
>
>I don't understand what you mean by this
>
By this I mean, I commented the line of code the read the first line of the
file and tested for the comment line of "# Netscape HTTP Cookie File".
Therefore the first read of the file was done when entering while loop. At
which point my cookie file only contained one line of text which was a
cookie. This produced successful results. Of course, I now have my own
version of Cookies.pm.
- Russ
---------------------------------------------------
Of course I don't look busy - I did it right the first time.
---------------------------------------------------
Russell Locke
ITG - Software Engineering
EMail: rlocke@hbs.edu
Phone: 617.495.6994
Fax: 603.688.6053
Internet: www.people.hbs.edu/rlocke
Harvard Business School
Cotting 213
Soldiers Field Rd.
Boston, Massachusetts 02163
USA