Re: STDIN reads everything as one line
I was the guy :) Strange, because the "Writing Apache Modules..." book explicitly tells you that you CAN do this (use STDIN to read the post line by line). Based on my experience, and your snippet below, I'm guessing the book is incorrect :) -jse From: "Eric L. Brine" [EMAIL PROTECTED] Date: Thu, 25 Nov 1999 01:39:44 -0400 To: [EMAIL PROTECTED] Subject: STDIN reads everything as one line A few days ago, someone mentioned doing $scalar = STDIN read the whole POSTed data. I stumbled upon the following in Apache.pm: #shouldn't use STDIN anyhow, but we'll be nice sub READLINE { my $r = shift; my $line; $r-read($line, $r-header_in('Content-length')); $line; } This snippet is the tied sub which handles line reads from STDIN. Apparently, his problem had nothing to do with $/ as was suggested. I guess he should be using $r to access the POSTed data. ELB -- Eric L. Brine | Chicken: The egg's way of making more eggs. [EMAIL PROTECTED] | Do you always hit the nail on the thumb? ICQ# 4629314 | An optimist thinks thorn bushes have roses.
Re: STDIN reads everything as one line
On Wed, 24 Nov 1999 22:33:55 -0800 "John S. Evans" [EMAIL PROTECTED] wrote in [EMAIL PROTECTED]: From: "Eric L. Brine" [EMAIL PROTECTED] A few days ago, someone mentioned doing $scalar = STDIN read the whole POSTed data. I was the guy :) Strange, because the "Writing Apache Modules..." book explicitly tells you that you CAN do this (use STDIN to read the post line by line). Based on my experience, and your snippet [above], I'm guessing the book is incorrect :) The angle operator is subject to the $/ variable's current setting, per perlvar(1) and perlop(1). Only when that variable's value is undef do you get the whole remainder of the input handle available as a single scalar value. % man perlfaq5 ... How can I read in an entire file all at once? The customary Perl approach for processing all the lines in a file is to do so one line at a time: open (INPUT, $file) || die "can't open $file: $!"; while (INPUT) { chomp; # do something with $_ } close(INPUT)|| die "can't close $file: $!"; This is tremendously more efficient than reading the entire file into memory as an array of lines and then processing it one element at a time, which is often--if not almost always--the wrong approach. Whenever you see someone do this: @lines = INPUT; You should think long and hard about why you need everything loaded at once. It's just not a scalable solution. You might also find it more fun to use the the standard DB_File module's $DB_RECNO bindings, which allow you to tie an array to a file so that accessing an element the array actually accesses the corresponding line in the file. On very rare occasion, you may have an algorithm that demands that the entire file be in memory at once as one scalar. The simplest solution to that is: $var = `cat $file`; Being in scalar context, you get the whole thing. In list context, you'd get a list of all the lines: @lines = `cat $file`; This tiny but expedient solution is neat, clean, and portable to all systems that you've bothered to install decent tools on, even if you are a Prisoner of Bill. For those die-hards PoBs who've paid their billtax and refuse to use the toolbox, or who like writing complicated code for job security, you can of course read the file manually. { local(*INPUT, $/); open (INPUT, $file) || die "can't open $file: $!"; $var = INPUT; } That temporarily undefs your record separator, and will automatically close the file at block exit. If the file is already open, just use this: $var = do { local $/; INPUT }; --tom
Re: STDIN reads everything as one line
When I wrote Apache::Filter, I decided to implement an honest-to-god full-on emulation of Perl's filehandle reading routines, and in particular it should handle $/ properly. If you want to have a look at that code, perhaps a portion of it could be integrated into Apache.pm so it would behave correctly. In Apache::Filter the filehandle is just tied to a scalar that contains the text in it. One filter prints to the filehandle, and another can read from it using any of Perl's built-in filehandle routines. By the way, won't newlines in the input be escaped into their hex equivalent anyway? Will this really work? [EMAIL PROTECTED] (John S. Evans) wrote: I was the guy :) Strange, because the "Writing Apache Modules..." book explicitly tells you that you CAN do this (use STDIN to read the post line by line). Based on my experience, and your snippet below, I'm guessing the book is incorrect :) -jse From: "Eric L. Brine" [EMAIL PROTECTED] Date: Thu, 25 Nov 1999 01:39:44 -0400 To: [EMAIL PROTECTED] Subject: STDIN reads everything as one line A few days ago, someone mentioned doing $scalar = STDIN read the whole POSTed data. I stumbled upon the following in Apache.pm: #shouldn't use STDIN anyhow, but we'll be nice sub READLINE { my $r = shift; my $line; $r-read($line, $r-header_in('Content-length')); $line; } This snippet is the tied sub which handles line reads from STDIN. Apparently, his problem had nothing to do with $/ as was suggested. I guess he should be using $r to access the POSTed data. ELB -- Eric L. Brine | Chicken: The egg's way of making more eggs. [EMAIL PROTECTED] | Do you always hit the nail on the thumb? ICQ# 4629314 | An optimist thinks thorn bushes have roses. ------ Ken Williams Last Bastion of Euclidity [EMAIL PROTECTED]The Math Forum
The Spirit of the... Mailing List
Well, lately there was a lot of frustration expressed by some of the folks, and I could guess that there are many others feeling the same way but prefer to keep they thoughts for themselves. This post is an attempt to revive the spirit of our beloved mod_perl mailing list. It seems that the pandora box was opened by the "make test" issue, so here is my take on it: Well, it works for *most* of the people. For those that doesn't and who solves the problem we patch the sources and I update the guide to point to solutions. As a matter of fact I've patched another 'make test' problem a few weeks ago. I've discovered it while installing mod_perl, solved it and sent the patch. It might take awhile to find out what the problem is, but the real joy is when you solve it - try it once, it's hard at the beginning but it worth every second/hour/day/week you spent on it. That's the programmer's joy - welcome to the programmers world :) Regarding the policies. You are lucky as this list is pretty good relative to other I used to lark at and left. The rate of helping is much higher here relative to the rate of flames. As a matter of fact other folks and me, are trying to calm down the flamers in case the flames are irrelevant. You can read through the archives, if you want to the proof. Jeffrey is a good guy and he really helps and contributes a lot, don't forget that we are all volunteers and spend our precious time helping out people. We could make more money at the same time or just getting some sleep, instead of helping at all. The reason not all questions are being answered is either that we don't know or don't have the time. There is also a term of "sexy question", if your doesn't fall into that category you might be out of luck. You should understand that when you flame on people who contribute, the flamed people say "what the heck, I'm out of here". Oops you've just lost yet another contributor. As for unanswered question, Matt Sergeant starts to provide a commercial services, like support and training and more people will join later. If you don't have the time/knowledge to learn things on your own, please consider using his commercial support. If you came to me and said: "Stas I'll pay you so you will not have to work to feed your family, please asnwer to all my questions", I would probably do that. And many other too. Please remember that we do what we do, because we beleive in a good world... Now, I don't claim that I know the humans nature, but I think that many of you "silent" listeners should get out of your hiding places and start getting involved into a project's life. Don't be surprised if one day the number of answers to the questions will come to zero. You should try to asnwer, at the beginning the simple questions, later when you gain the confidence a more complicated ones. Please remember that no one, I stress NO ONE, will flame on your that you gave a wrong answer. Just claim that: I'm not sure whether I'm correct, but possibly this should solve your problem. You aren't in the court, you are in the place that alive only for a sole reason that someone have the guts to help. Why going far, take myself for example - look at the archives, 2 years ago I was asking stupid questions, with time I've learned a bit, but I was afraid to answer someones questions because I wasn't sure I was right. But later it hit me, I understood that because the gurus has to asnwer stupid questions they didn't make it to the real complicated ones. So I've decided: hey, if I try to take the load off the gurus they will ask more of my questions. And you know what, it worked I've tried to asnwer questions and do it more or less until today whether I know the asnwer or not. When I don't, at least I try to suggest something, many times the person that has asked the question finds the answer himself, all she needed is to be listened... BTW, that's how the guide was born (the 1 year anniversary celebrations will be announced in December :) To summarize my rumblings: * We are all volunteers - please remember that. If you want to get all the asnwers, you should consider paying for that. = Since we are volunteers we do that for fun, that's one of the reasons why some of the questions go unasnwered (the sexy syndrom) = The other reason, is that we don't always have time = The third reason, is that we cannot always reproduce the problems in question. * Don't forget that there is no free meal! Use the help you get on the list, but don't abuse it. But not abusing I mean: = Give back! Don't afraid to contribute and disregard the post of people who think too much about themselves. If you have a problem try to solve it first by yourself - once you solve it, you will feel very proud of yourself and hey, you have learned something! Don't forget to tell the list how did you make it. = Be gentle. Don't flame for nothing. Especially if your flaming target's intentions were good by her understanding,
Re: The Spirit of the... Mailing List
One more thing. If you know the answer is in the Guide, do a search on it, and present the newbie with the appropriate link. It will not take more than one or two times for the newbie to realize they should check the guide first for the answers. If not, lets face it, they will never get something as powerful and complex as mod perl working for them effectively and they need to use a simpler solution. thanks to Stas for the Guide. cliff rayman genwax.com Stas Bekman wrote: Well, lately there was a lot of frustration expressed by some of the folks, and I could guess that there are many others feeling the same way but prefer to keep they thoughts for themselves. This post is an attempt to revive the spirit of our beloved mod_perl mailing list. It seems that the pandora box was opened by the "make test" issue, so here is my take on it: Well, it works for *most* of the people. For those that doesn't and who solves the problem we patch the sources and I update the guide to point to solutions. As a matter of fact I've patched another 'make test' problem a few weeks ago. I've discovered it while installing mod_perl, solved it and sent the patch. It might take awhile to find out what the problem is, but the real joy is when you solve it - try it once, it's hard at the beginning but it worth every second/hour/day/week you spent on it. That's the programmer's joy - welcome to the programmers world :) Regarding the policies. You are lucky as this list is pretty good relative to other I used to lark at and left. The rate of helping is much higher here relative to the rate of flames. As a matter of fact other folks and me, are trying to calm down the flamers in case the flames are irrelevant. You can read through the archives, if you want to the proof. Jeffrey is a good guy and he really helps and contributes a lot, don't forget that we are all volunteers and spend our precious time helping out people. We could make more money at the same time or just getting some sleep, instead of helping at all. The reason not all questions are being answered is either that we don't know or don't have the time. There is also a term of "sexy question", if your doesn't fall into that category you might be out of luck. You should understand that when you flame on people who contribute, the flamed people say "what the heck, I'm out of here". Oops you've just lost yet another contributor. As for unanswered question, Matt Sergeant starts to provide a commercial services, like support and training and more people will join later. If you don't have the time/knowledge to learn things on your own, please consider using his commercial support. If you came to me and said: "Stas I'll pay you so you will not have to work to feed your family, please asnwer to all my questions", I would probably do that. And many other too. Please remember that we do what we do, because we beleive in a good world... Now, I don't claim that I know the humans nature, but I think that many of you "silent" listeners should get out of your hiding places and start getting involved into a project's life. Don't be surprised if one day the number of answers to the questions will come to zero. You should try to asnwer, at the beginning the simple questions, later when you gain the confidence a more complicated ones. Please remember that no one, I stress NO ONE, will flame on your that you gave a wrong answer. Just claim that: I'm not sure whether I'm correct, but possibly this should solve your problem. You aren't in the court, you are in the place that alive only for a sole reason that someone have the guts to help. Why going far, take myself for example - look at the archives, 2 years ago I was asking stupid questions, with time I've learned a bit, but I was afraid to answer someones questions because I wasn't sure I was right. But later it hit me, I understood that because the gurus has to asnwer stupid questions they didn't make it to the real complicated ones. So I've decided: hey, if I try to take the load off the gurus they will ask more of my questions. And you know what, it worked I've tried to asnwer questions and do it more or less until today whether I know the asnwer or not. When I don't, at least I try to suggest something, many times the person that has asked the question finds the answer himself, all she needed is to be listened... BTW, that's how the guide was born (the 1 year anniversary celebrations will be announced in December :) To summarize my rumblings: * We are all volunteers - please remember that. If you want to get all the asnwers, you should consider paying for that. = Since we are volunteers we do that for fun, that's one of the reasons why some of the questions go unasnwered (the sexy syndrom) = The other reason, is that we don't always have time = The third reason, is that we cannot always reproduce the problems in question.
Problem accessing DBI from EmbPerl
hi list, I'm running Embperl on my ISPs webserver, and when I execute the following code (from the sample included with Embperl): === $DSN = 'dbi:mysql:mlanghoff' ; $table = 'registros' ; use DBI ; # connect to database $dbh = DBI-connect($DSN, 'mlanghoff', 'ml123') or die "Cannot connect to '$DSN' $!" ; # prepare the sql select $sth = $dbh - prepare ("SELECT * from $table") or die "Cannot SELECT from '$table'" ; # excute the query $sth - execute or die "Cannot execute SELECT from '$table'"; ##This is line 29!!! I get the following error : [22828]ERR: 32: Line 15: Warning in Perl code: DBD::mysql::st execute failed: ase Selected at /usr/local/httpd/htdocs/intercosta/htmlf/dbi1.netizen.ehtml line 29. [22828]ERR: 24: Line 15: Error in Perl code: Cannot execute SELECT from 'registros' at /usr/local/httpd/htdocs/intercosta/htmlf/dbi1.netizen.ehtml line 29. And the server signature: Apache/1.3.4 (Unix) SuSE/6.0 PHP/3.0.6 mod_perl/1.17 HTML::Embperl 1.2.0 [Fri Nov 26 18:27:40 1999] I've been told by the webmaster that DBI connections fail from ePerl also, so maybe it's a mod_perl issue. Anyway, the webmaster doesn't care much about it, but I ***must*** make it work. Do you have any pointers as to where can I start debugging this issue? The same code runs perfectly on my local linux, and DBI runs great from any standard CGI scripts run with the standalone perl interpreter. Thanks in advance. martin -- - Martin Langhoff @ S C I M Multimedia Technology - - http://www.scim.net | God is real until - - mailto:[EMAIL PROTECTED] | declared integer -
How to (not) get help (was: make test fails (modules/src.t) withError 29)
On Wed, 3 Nov 1999, G.W. Haywood wrote: Hi Greg, First a link to an article Mark-Jason Dominus once wrote about "Why questions go unanswered". http://www.plover.com/~mjd/perl/Questions.html Read it and read it again, it gives some insight to what to do and how to write to get help on mailinglists and in newsgroups. You could also have done a better job at marking out what of the 33kb you sent was important or relevant. It was an awful long mail to go through. You also forgot to send us the Makefile.PL parameters you used. Apache::src seems to not work when you have your mod_perl tree in a subdirectory to your apache tree. How you got it to compile is mysterious to me though, you must have been doing something funky. When I try that it both screams and yells at me that it can't find the apache src. Try with freshly unpacked tar files, and don't put the mod_perl under the apache-1.3 directory. What does it say then? - ask PS. Flaming people who try to help you have never done any good, not even when you're frustrated and think they could do better at helping you. Especially flaming the software a lot of people have worked hard on often in their precious sparetime is an effective way to get ignored. A lot of the very helpful and clued people on this mailinglist get payed well for spending their time not helping people on this list, but they still do it. Don't discourage them. The way to get help is either 1) Do you homework and stay with the nice attitude or 2) Don't do you homework but find the checkbook and stay with the nice attidude. Nobody wants to work for or with someone who is rude. modules/src.Use of uninitialized value at modules/src.t line 19. Use of uninitialized value at modules/src.t line 20. Use of uninitialized value at ../blib/lib/Apache/src.pm line 164. Use of uninitialized value at modules/src.t line 27. Use of uninitialized value at ../blib/lib/Apache/src.pm line 215. Use of uninitialized value at ../blib/lib/Apache/src.pm line 215. can't stat No such file or directory 1..6 ok 1 dir=../src ok 2 main= not ok 3 module_magic_number = 0 not ok 4 httpd_version = not ok 5 -I../src -I../src/modules/perl -I dubious Test returned status 2 (wstat 512, 0x200) DIED. FAILED tests 3-6 Failed 4/6 tests, 33.33% okay -- ask bjoern hansen - http://www.netcetera.dk/~ask/ more than 60M impressions per day, http://valueclick.com
Re: How to (not) get help (was: make test fails (modules/src.t) withError 29)
On Fri, 26 Nov 1999, Ask Bjoern Hansen wrote: Hi Greg, eh, make that Ged. I'm up too early. (7.something here, argh.) - ask -- ask bjoern hansen - http://www.netcetera.dk/~ask/ more than 60M impressions per day, http://valueclick.com
APACHE_HEADER_INSTALL
Maybe I'm going crazy, but I'm sure last time I used APACHE_HEADER_INSTALL=0 and the make install worked just fine. But this time I get: "Warning: You do not have permissions to install into /usr/local/perl5.005/lib/site_perl/5.005/..." Perhaps I'm confused, but isn't that what APACHE_HEADER_INSTALL=0 is suppose to avoid? And I also get: "Cannot forceunlink /usr/local/perl5.005/lib/site_perl/5.005/sun4-solaris/auto/Apache/Leak/Leak. so" These are the two methods I tried: perl Makefile.PL \ APACHE_PREFIX=$HOME/httpd_heavy \ APACHE_HEADER_INSTALL=0 \ EVERYTHING=1 And: perl Makefile.PL \ APACHE_PREFIX=$HOME/httpd_heavy \ APACHE_HEADER_INSTALL=0 \ APACHE_SRC=../apache_1.3.9/src \ DO_HTTPD=1 \ USE_APACI=1 \ EVERYTHING=1 Thanks, Bill Moseley mailto:[EMAIL PROTECTED]