Re: unsubscribe
fREW Schmidt wrote: How many times to people have to tell you to look at the headers of the e-mail for the list management addresses? --mark-- When using gmail it's not exactly obvious. I agree with someone who posted a few days ago. It wouldn't hurt to put it in a footer. By default, my mailer doesn't show headers so I'd have to choose View all headers in the menu. The point, I think, is that when someone has decided to leave, unless they're changing e-mail addresses, they're basically an unsatisfied customer and we can't expect them to do too much as they are leaving. That might also include visiting the web site of this mailing list. I also support a footer of either the unsubscribe address or the URL of this list. Another list that I'm on sends out an automated e-mail once a month (always first of the month). A bit annoying and I question its usefulness if someone wants to leave at the end of the month... :-) Ray
Re: Apache2::Reload: Where is it?
Hello, fREW Schmidt wrote: I am trying to use Apache2::Reload for development, and I apparently configured my server incorrectly because I get these errors when I include the PerlMode Apache2::Reload and PerlInitHandler Apache2::Reload directives I get these errors: [Thu Jan 15 17:34:21 2009] [error] Can't locate Apache2/Reload.pm in @INC (@INC contains: C:/usr/site/lib C:/usr/lib . C:/Program Files/Apache Software Foundation/Apache2.2) at (eval 3) line 3.\n [Thu Jan 15 17:34:21 2009] [error] Can't load Perl module Apache2::Reload for server (null):0, exiting... Can you confirm that it exists on disk? I don't know the standard directory for a Windows machine [which is what you seem to be using], but at least on the Linux machine I am using, I had to explicitly install Apache2::Reload. Is there a Reload.pm file somewhere on your hard disk? If yes, then you add the path to it...if no, then you would need to install it. Ray
Re: Setting LD_LIBRARY_PATH for a forked process
Hi Torsten and Heiko, Heiko Jansen wrote: Am Freitag, den 09.01.2009, 10:25 +0100 schrieb Torsten Foertsch: On Fri 09 Jan 2009, Raymond Wan wrote: It is possible I'm doing something wrong, but so far, this isn't working. And if I replace the $cmd with a Perl script and try to print out $ENV{LD_LIBRARY_PATH}, there is nothing. I think you need this one: http://search.cpan.org/~stas/Env-C-0.08/C.pm Perhaps also possible: replace the program that gets executed with a shell script that sets the env param and then does exec realcmd $@. Or even more simple: change the command string in your perl script to something like 'LD_LIBRARY_PATH=... realcmd'. Of course that's far less elegant than using Env::C but I believe it should work. Thank you both for your replies! I thought I'd give Env::C.pm a try first and yes, worked like a dream! Thank you for giving me the alternatives, Heiko. Is there an easy explanation why I needed Env::C? Part of the documentation for it says, if these variables are set in Perl and the glue code doesn't worry to set them on the C level, these variables might not be seen by the C level. The way this is phrased makes it seem very generic. Does C level just mean anything that a Perl script calls? It could be a library in C or an entirely separate program; but basically environment variables that aren't being passed from the script to something else (that may or may not be related to C -- could be a java program). Thanks both of you for your help! Ray
Setting LD_LIBRARY_PATH for a forked process
Hi all, I'm developing a web server which forks a process and then the child process goes off and does some processing and I do not want to wait for it to return. The child process runs a C++ program (i.e., not a Perl script). Thanks to replies here a while back, I got things working by performing a fork followed by a system. So all was well... Now, things have changed slightly and the C++ program needs to make use of shared libraries and right now, it cannot find them. Does anyone have any suggestions on how I would do that? Obviously, I need to update $LD_LIBRARY_PATH; but how would I do it? Currently, I'm doing something like this: - use Env qw(LD_LIBRARY_PATH); my $cmd = ...; my @args = (...); $ENV{LD_LIBRARY_PATH} = new path; ## Or prepend to it my $kid = fork; if (!defined $kid) { ## Some error happened } elsif ($kid == 0) { ## Open/close filehandles, etc. ## Run the command system ($cmd, @args); CORE::exit (0); } ## Parent process continues here... - It is possible I'm doing something wrong, but so far, this isn't working. And if I replace the $cmd with a Perl script and try to print out $ENV{LD_LIBRARY_PATH}, there is nothing. Am I close? I've googled a bit and I lost the page that I saw it (went to too many pages), but one person put $cmd and the updated environment variable into a bash script and then ran the bash script. Any other thoughts? Thank you! Ray
Re: Best filesystem type for mod_cache in reverse proxy?
Hi Michael, Michael Peters wrote: Raymond Wan wrote: I had looked at the effect compression has on web pages a while ago. Though not relevant to modperl, there is obviously a cost to compression and since most HTML pages are small, sometimes it is hard to justify. Not to discredit the work you did researching this, but a lot of people are studying the same thing and coming to different conclusions: http://developer.yahoo.com/performance/rules.html Yes, backend performance matters, but more and more we realize that the front end tweaks we can make give a better performance for users. Take google as an example. The overhead of compressing their content and decompressing it on the browser takes less time than sending the same content uncompressed over the network. I'd say the same is true for most other applications too. It's ok; I don't consider another opinion as discrediting my work. :-) Actually, it was a while ago and it was only one aspect of my work and in a smaller test bed. My fault for handwaving in my reply, though. The point is actually the sometimes... My research was more in general compression and web compression was only one aspect. My point is if you take a one byte file and run gzip -9 on it (again, the same algorithm as deflate), you get a 24 byte file. As you increase that file size, you will reach a point where it becomes more beneficial to compress. Though my example is both silly and pathological, it just shows that there are cases when compression may not be beneficial. And one can imagine the average file size of a web site to be some kind of knob and as it turns (average file size increases as you go from site to site), the benefits become more and more evident. For example, compressing an already compressed file is generally pointless (if it was done right the first time). MP3, JPEG, GIF, etc. are all file formats that have or may have compression incorporated. PDFs can be compressed too if someone selected that option when creating it. English text compresses well (25%, in general?) but two-byte encodings such as Chinese and Japanese (I think) get around 40-50% [handwaving again :-) there are more updated numbers out there]. Also, compression works if it is a uniform file; if a web page has a mix of text, images, etc., then each one has to be compressed individually. As for Google, you are right -- I can imagine why it would work well for Google. However, I can also hypothesize that it might be a special case. I presume you mean the results of a query. The result we get is a list of results which all are related to each other. i.e., if you searched for apache2 modperl, we can expect those two words to be in every result and the type of words to be similar from result to result [they would all be computer-oriented]. As compression aims to reduce redundancy, their results are perfect for it. Especially if Anyway, what I wanted to say is that there ought to be instances when compression is beneficial and when it isn't. I think it is fine to do what the Yahoo site says and have it on by default; but if someone examines the traffic and data and realizes it should be off, that isn't beyond reason. As for dialup, if I remember from those dark modem days :-) Even non dialup customers can benefit. Many broadband connections aren't very fast, especially in rural places (I'm thinking large portions of the US). But all this talk is really useless in the abstract. Take a tool like YSlow for a spin and see how your sites perform with and without compression. Especially looking at the waterfall display. Well, one good thing about deflate is that it is *fast*. Very fast. So, while my silly one byte file example shows there are exceptions, it might be closer to one byte. :-) One cost savings might be to pre-compress files since it is more time-consuming to compress than decompress using deflate. i.e., have them reside on the server in compressed form. Of course, that offers many problems and is one reason why things like Stacker didn't really catch on (much)... Ray
Re: Best filesystem type for mod_cache in reverse proxy?
Hi Neil Gunton wrote: Well, that seemed to do the trick! So the caveat seems to be: Be careful using both mod_deflate and mod_cache (mod_disk_cache specifically) together if you have a large dynamic website that can generate a large number of distinct pages. Mod_deflate produces a This is probably a digression from your discussion, but I'm not sure if any of you have used gzip + md5sum together before. I have, and it can be annoying especially if you are playing with large data files like I do. This is because gzip seems to (not 100% sure) store some time information in the archive. So, if you create two archives of the same files, they aren't identical...their md5sums do not match. As deflate is essentially the same algorithm as gzip, it is somewhat the same annoyance... Web pages seem to render a little faster in the browser too. That may be my imagination and/or placebo effect, but it might make sense if there isn't that additional compression/decompression going on both ends. The only downside is that people on extremely slow dialup connections might notice longer download times for page text... but I have to wonder if that's really an issue today. Back in 1998 perhaps you might care about something being 20KB rather than 80KB, but surely not today. In any case, don't dialup ISPs often implement their own compression now? I had looked at the effect compression has on web pages a while ago. Though not relevant to modperl, there is obviously a cost to compression and since most HTML pages are small, sometimes it is hard to justify. If users are downloading XML files of data, though, then that is of course worth it...but one could argue that if you are making XML files available for download, then wouldn't it be better to compress it yourself rather than asking Apache to compress on-the-fly. As for dialup, if I remember from those dark modem days :-), even many of them had compression built in. In fact, I think they had some form of the deflate/gzip/sliding window algorithm. And for those of us who have tried gzipping an already-gzipped file, adding compression to something that is already compressed is generally counter-productive... Anyway, I don't think it is much of an issue...might be more helpful to educate web page creators to not put MBs of images on a single page. :-) Ray Anyway, hope that's helpful to anybody running large dynamic websites behind a reverse proxy. Keep mod_cache, maybe think about ditching mod_deflate. The combination does technically work, but for large numbers of pages, it can make your cache size (and your iowait) explode.
Re: Strange message in web page
Hi Ronald, Ronald J Kimball wrote: Those are the HTTP response headers. They are showing in the browser because your script is returning a malformed response, i.e. printing null device 1 before the headers. The browser is unable to parse the headers and treats them as part of the body. Thanks for this; I still haven't been able to figure out why it is doing this, but it gives me an idea of what to look for. I didn't know one could print something before headers; but it sounds like I'm doing something very wrong... Thanks a lot -- will keep looking... Ray
Re: Problem getting started
Hi John, Unfortunately, I'm still muddy with modperl to help you even though I'm on Debian Etch. I have it working and can tell you what I have installed...but I can't help you with modperl specifics as I'll probably end up teaching the wrong thing. To answer Adam's question: Adam Prime wrote: John M. Dlugosz wrote: I'm trying to use mod_perl on Debian Etch. I was looking at practical mod_perl book, but it appears that much has changed in mod_perl 2.0 so the second example doesn't work at all. I personally normally install mp and libapreq from source, so i'm not familiar with how one would install/configure them using debian. aptitude install libapreq2 as root (or sudo). Or just install everything related if you are not sure: aptitude install libapache2-mod-apreq2 libapreq2 libapreq2-dev libapreq2-doc (I have all of them installed.) Of course, apt-get works too, if you prefer that. I don't remember doing more configuration. There's a symlink from /etc/apache2/mods-enabled/apreq.load to /etc/apache2/mods-available/apreq.load Sorry, can't think of anything else tricky that I did. I hope this is enough. Ray
Re: Problem getting started
Hi John, John M. Dlugosz wrote: OK, when I defined $r as you did, it worked. For documentation, I was looking at here: http://search.cpan.org/~joesuf/libapreq2-2.08/glue/perl/lib/Apache2/Request.pm I see you are just printing to standard output, like a CGI script. In the book, it used $r-send_http_header('text/plain'); $r-print(mod_perl rules!\n); but there are no such methods on $r here in 2.0. What, prey tell, is the equivalent object? Is there =any= way to get started, like a simple (but working!) program I could look at? When I was starting with modperl2, I had similar problems to you. I'm more of a book-person, and many of the books (such as the O'Reilly ones) have not been re-released for modperl2. While there is a lot of information on the web, it isn't as easy sifting through it all. As for your question, the $r object is (I believe :-) ) the RequestRec object: http://perl.apache.org/docs/2.0/api/Apache2/RequestRec.html and instead of send_http_header, you would use content_type. As mentioned here which describes porting mod_perl 1.0 to mod_perl 2.0: http://perl.apache.org/docs/2.0/user/porting/compat.html#C__r_E_gt_send_http_header_ You may need to use these two documents (at least) in conjunction with the book you are reading to make any sense of it. Hope this helps! Ray
Strange message in web page
Hi all, I'm receiving a strange message which I think is caused by something I'm doing with modperl and/or Mason, but I'm not sure what to look for. Basically, I have a page which refreshes every 3 seconds waiting for some spawned child process to complete. When it completes, it stops refreshing (which is expected), but it also displays this at the top of the page: null device 1 HTTP/1.1 200 OK Date: Fri, 11 Jul 2008 09:40:57 GMT Server: Apache/2.2.3 (Debian) DAV/2 SVN/1.4.2 mod_python/3.2.10 Python/2.4.4 PHP/5.2.0-8+etch11 mod_apreq2-20051231/2.6.0 mod_perl/2.0.2 Perl/v5.8.8 Refresh: 3; url=http://... Keep-Alive: timeout=15, max=84 Connection: Keep-Alive Transfer-Encoding: chunked Content-Type: text/html; charset=UTF-8 998 I would prefer to not give this information out, but I'm also wondering if this is indicating some other problem. (null device does not sound good...) I do not know if this is relevant, but my code for forking is below: - $ENV{'PATH'} = '/bin:/usr/bin'; delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'}; $SIG{CHLD} = 'IGNORE'; defined (my $kid = fork) or die Cannot fork: $!\n; if ($kid) { chdir $HOMEDIR; } else { setsid () or die Can't start a new session: $!; open STDIN, '/dev/null' or die Can't read /dev/null: $!; open STDOUT, '/dev/null' or die Can't write to /dev/null: $!; open STDERR, '/dev/null' or die Can't write to /dev/null: $!; exec $cmd or die Cannot execute exec: $!; } - And to make it refresh, I am doing this Mason code (in another file): % $r - headers_out - set (Refresh = 3; url=$url); Of course, I don't know if either one of these snippets are the source of my problem. I also run the same server elsewhere administered by someone else more knowledgeable than me and I'm not getting the problem there...so, it could be a server setting. But, I'm not sure what to look for in the Apache documentation. Does anyone know what the problem is or where I should be looking? Thanks in advance! Ray
Re: Strange message in web page
Hi John, I see...I didn't know it was possible to print anything before headers... I am not printing that statement, as far as I know, but maybe a library I am using is. I will look into it... So, the part after HTTP/1.1 ..., why is that shown? Is that a web server setting? What is odd is that it doesn't print at every page. Just one page...and that one page doesn't always show it...only sometimes. This is why it is strange to me...but I'll keep looking, then. So, this is unrelated to modperl...other than debugging code somewhere? Thank you! Ray John Gateley wrote: ... but it also displays this at the top of the page: null device 1 HTTP/1.1 200 OK Date: Fri, 11 Jul 2008 09:40:57 GMT ... You are printing null device 1 to stdout somewhere in your code before you print the headers. Check for debugging statements.
Timing a spawned process
Hi all, I'm having a problem with spawning a long-running process and timing it (i.e., with /usr/bin/time, for example). A while back, I posted a problem with spawning a process which I did not want to know if/when it comes back. Based on many helpful replies, I am now using: - $ENV{'PATH'} = '/bin:/usr/bin'; delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'}; $SIG{CHLD} = 'IGNORE'; defined (my $kid = fork) or die Cannot fork: $!\n; if ($kid) { ## Parent has finished } else { setsid () or die Can't start a new session: $!; open STDIN, '/dev/null' or die Can't read /dev/null: $!; open STDOUT, '/dev/null' or die Can't write to /dev/null: $!; open STDERR, 'STDOUT' or die Can't dup stdout: $!; exec $cmd or die Cannot execute exec: $!; } - I am interested in timing $cmd. If I just wanted the real time, I could just record the time when the process starts and when it stops. However, what I'm more interested in is the user time. I guess [and I could be wrong...] that the easiest way to do it is to have /usr/bin/time at the front of $cmd. When I put that, I get an error like: /usr/bin/time: error waiting for child process: No child processes $cmd is actually a C executable. So, I changed it to a bash script that runs the executable and in the script, I put /usr/bin/time again. I'm not sure if this was a silly thing to try, but it didn't work and I'm not sure if it is because of my Perl code above. It seems like I'm either misunderstanding something or just doing it wrong, but I don't quite know what. Is there anyway for me to get the user time of $cmd? Thank you in advance! Ray
Forking a process [in Practical mod_perl book]
Hi all, I'm trying to fork a long-running process which I do not want to wait for. I was getting a lot of ssh defunct processes, so I did some googling and found this from the aforementioned O'reilly book: http://www.perl.com/lpt/a/701 And sure enough, there's a section on Avoiding Zombie Processes. In this section's example code, the authors have added these two lines to the top: - my $r = shift; $r-send_http_header('text/plain'); - which did not exist in the previous examples. I don't quite understand why setting the HTTP header has any relevance to zombie processes. Apologies if I missed it somewhere on this page, but could anyone shed some light on why these two lines are important enough to remain in all future examples on this topic? Thank you! Ray
Re: Forking a process [in Practical mod_perl book]
Hi all, Raymond Wan wrote: - my $r = shift; $r-send_http_header('text/plain'); - Sorry for the trouble but while googling for the problem, I came by the reason: send the output of system() to the client: http://www.mail-archive.com/[EMAIL PROTECTED]/msg36062.html I also realized that the solution for modperl1 differs for modperl2 and the above snippet seems relevant to MP1... Thanks! Ray
Re: return DECLINED or OK?
Hi, J. Peng wrote: On Fri, Feb 29, 2008 at 7:03 PM, Torsten Foertsch [EMAIL PROTECTED] wrote: Example continued: The entry /var/www/a/b exists on disk either as file or as directory but /var/www/a/b/c does not. Then after MapToStorage $r-filename is /var/www/a/b and $r-path_info is /c/d/e. Sorry I can't understand for this. If /var/www/a/b exists but /var/www/a/b/c not, why user requests it? What's $r-path_info? How to get path_info from filename? thanks again. I'm not sure if I can help by cutting in here as I'm some what learning Apache and modperl myself. $r is not a file or a filename. This is Perl, remember? :-) So, $r is a scalar variable and, to be precise, the global variable for the Apache RequestRec object. Take a look at: http://perl.apache.org/docs/2.0/api/Apache2/RequestRec.html and http://perl.apache.org/docs/2.0/api/Apache2/RequestRec.html#C_path_info_ to see what Torsten meant by the path_info. As for /var/www/a/b/c, a user can request for a file that does not exists. The key is what Torsten said about walking the hierarchy. So, if /var/www/a/b/c/d/e does not exist, it sees if /var/www/a/b/c/d exists. If not, it tries /var/www/a/b/c/. It continues doing this, walking [up] the hierarchy, until it finds a match. In Torsten's example, this would be: /var/www/a/b/ Then, the RequestRec object now stores two parts. A filename /var/www/a/b/ and a path_info /c/d/e. Why would you want to do that. Well, an example that I saw in the Mason Book (Note: don't confuse yourself with learning this right now, but I just want to mention where I got the example from) which helped me understand this was as follows. Say you have a news site like: http://example.com/archive/news/2008/02/29/index.html A user might request that, but it wouldn't make sense to have 365 index.html's every year (ok, 366 this year :-) ). Instead, you could do a trick above and keep going up the hierarchy until you have a filename /var/www/archive/news/ and a path_info /2008/02/29/index.html. You can then use the path_info as a query string to some database to retrieve today's news. i.e., you don't actually have a file sitting at: /var/www/archive/news/2008/02/29/index.html but the user doesn't know this and probably doesn't care as long as s/he can see today's news. I hope this helps and I hope I didn't mess up your example, Torsten. If so, please correct me for my benefit, as well! :-) Ray
Re: return DECLINED or OK?
J. Peng wrote: Do you mean mod_rewrite for the trick? yes with mod_rewrite people can rewrite: http://example.com/archive/news/2008/02/29/index.html to something like: http://example.com/archive/news?object=/2008/02/29/index.html so here /archive/news is filename and /2008/02/29/index.html is path_info,is it? But in this case we don't need to guess the path_info from filename, just saying $r-param() can get the arguments,:) No, that's not what I meant and I also wasn't aware of mod_rewrite. :-) Might I make a suggestion? It seems this discussion has moved quite beyond the original subject. This (in my humble opinion) is not something you learn in a day. Well, I certainly didn't. I think you'll pick it up in time and one starting point is to write some sample code and try things out... Ray
Re: MapToStorage and the use of path_info (was Re: return DECLINED...)
Hi Frank, Frank Maas wrote: I am using a mechanism where I use the path_info to carry information about the content to be served. However, as far as I know the only way to do this is to create a handler that is defined for the correct location. In the described situation, something like, I have to confess that as I learned Mason first, I have problems separating it from modperl. So, how one would do it the modperl (only) way is something that I probably can't put into words and if I did, I probably would get it wrong. So, I'll have to let someone else answer you...sorry! The Mason way (and my news example) was taken from here: http://www.masonbook.com/book/chapter-3.mhtml#TOC-ANCHOR-8 And this is in fact something that I am doing on my site to move up [or down :-) ] it, but not with news. As Mason is used for templating, the Mason way could be the same as the modperl way. If you want to know the details of the Mason way, you can read that chapter, but this book seems out-dated and relevant to modperl 1. Sorry I cannot be of more help! Ray
Re: return DECLINED or OK? [off-topic]
Colin Wetherbee wrote: Ronald Dai. wrote: Actually RTFM would not be a problem for people from academic background (meaning MS or PHD educated) at all since they have to do it all the timebut for people with more team work background these days, it might not be politically very correct... I disagree. Granted, I have a master's degree. I should point out that one could be educated without a MS or a PhD. One could also be uneducated with a MS and/or a PhD. It depends on one's quality of education and their self-motivation in RTFM. But I know that Ronald is saying it casually, just like the expression being a rocket scientist which is probably an out-dated expression now. But, let's say, as very nearly happened on another mailing list yesterday, someone installs database software and can't figure out how to create a database. I say go look at the manual and here's the specific URL that covers creating new databases. Now, that person knows where to look for information about creating a database, *and* that person also knows where to look for answers to future simple questions. I totally agree with this and I think that one has to know the material before working as a group. Some university courses are so caught up in the terminology like team work, they seem to jump a step. Just like it would be good to learn how to add before you can use a calculator. Yes, everyone nowadays uses a calculator -- it is in high school curriculum now and it is also the real world -- but strange to focus on the calculator if someone does not even know how to do the operations that a calculator does... Ray
Re: MapToStorage and the use of path_info (was Re: return DECLINED...)
Joy, J. Peng wrote: I'm still confused why we need a path_info for the additional info to CGI/modperl scripts? Generally under CGI we say x.cgi?key=value to pass arguments, under modperl handler we say /myHandler/?key=value to do it, or using POST method. Under what case we use path_info? How about this for an explanation. In the first scenario with the ?, you are passing arguments explicitly using key/value pairs as if it was part of the URL sent by the web browser. In the second scenario, nothing is being passed as key/value pairs. Instead, the server searches up/down the directory hierarchy until it finds a match and everything after the match becomes the argument. In the first scenario when you are splitting the path into key/value, you need to know where to split it. How? Perhaps by doing a file test with each split yourself? In the second case, you don't need to worry about it. Not a very technical answer, but maybe an easy way of thinking of things. The second scenario also makes it possible for Google, etc. to index your web pages since it is a real URL. In the first case, it is possible, but not as straight-forward. Ray
Re: Amazon
Hi, One of the first things I would look is their job postings...if they are switching, that would be one sign. Indeed, I saw a few software development jobs on amazon asking for Java and C/C++ experience. Only found one asking for any two of Java, C/C++, and Perl. Of course, this is just a hint...they may be hiring people to maintain their payroll database, etc. But you might want to watch their jobs DB to see if there is any trend they're moving toward... Ray Jonathan Vanasco wrote: I've heard from a few reputable sources that Amazon is looking to drop mod_perl, and push into another technology ( which I've also head is likely to be Java ).
Re: handler using a module
Hi Malcolm, Malcolm wrote: Mason uses it's own namespace for the code it generates from your templates. So unless you have a use lib...; use myOwnFunctions; in your template, it won't have your functions in scope. I see. So if myOwnFunctions is used by many of my components, there is no way to have it load once but used by all of the components? That was my motivation for putting the two use lines in the handler. I guess in the end, the added execution time is small; I was just wondering if there was a more efficient way of doing it. imports myOwnFunctions into the myHandler namespace, which is visible from Mason (either because you did a use or through Mason magic). I see -- thank you for the explanation! Ray
handler using a module
Hi all, I have written a handler to take care of requests and there is something unexpected [to me, anyway :-) ] happening which may be my fault, but I was wondering if someone can explain it to me. Perhaps there is a problem with my programming style. The code is long, so I'll briefly mention what I think is relevant [hopefully I don't leave anything out]. I have a handler called myHandler.pl: - ## File myHandler.pm package myHandler; use lib 'my Path'; use myOwnFunctions; ## Located in my Path my $ah = HTML::Mason::ApacheHandler - new (...); sub handler { my $r = shift; $ah - handle_request ($r); } 1; - In the file myOwnFunctions.pl: package myOwnFunctions; sub myFunction { } 1; - So in an HTML file that will be processed by Mason, I call myFunction () and it says it is undefined. This surprised me since I indicated that I am using myOwnFunctions in the handler with the use directive. Is that not the way to do it? So, then I thought I should call myFunction as: myOwnFunctions::myFunction () and that gave me an error. By accident, I typed: myHandler::myFunction () and that worked... I don't quite know why. I presume I have done a mistake somewhere. Or is this how it should be? Thanks! Ray
Re: handler using a module
Hi Marcel, Marcel Greter wrote: I can only tell why myHandler::myFunction () is working. I think you export the myFunction in Module myOwnFunctions. I assume you didn't post that part of the code? Ah, yes -- I didn't think that was doing it but yes, I also have: require Exporter; our @ISA = qw (Exporter); our @EXPORT = qw (myFunction); our @EXPORT_OK = qw (myFunction); Therefore myFunction is also accessible within the namespace myHandler, and therefore the second version is working as I would expect. But I cannot tell you why myOwnFunctions::myFunction itself is not working. Hmmm, I see. Is there any problem if I continue with myHandler::myFunction () for now? Maybe later on, I will figure out what is wrong...perhaps some other silly mistake that I also didn't post? I will continue investigating... As someone new to Mason and modperl, what is the correct way of doing this? i.e., the correct practice? Should myOwnFunctions be exporting? More importantly, should I do this: use lib 'my Path'; use myOwnFunctions; ## Located in my Path I thought by doing so, it loads myOwnFunctions once per process. But I'm having doubts about whether what I'm doing makes any sense... :-) Thank you! Ray
Re: Unsubscribe request
Hi Vijayram, Vijayram Arya wrote: I would like to be unsubscribed from this mailing list, I kindly request the moderator to unsubscribe me.. Take a look at this web site and do what it says to unsubscribe yourself: http://perl.apache.org/maillist/email-etiquette.html#To_Get_Off_The_List Ray PS: Purposely sending this out to the mailing list so that Vijayram doesn't get hundreds of messages with the same link -- or is that punishment for not reading the FAQ? :-)
Cookie questions
Hi all, Sorry, but I'm not entirely sure if this is relevant to modperl... I was wondering if it was possible to delete cookies. I read that using Javascript, cookies can be deleted by setting it to a time in the past. I'm not sure how to do it in Mason, though. I think I know how to get a cookie and also to set a new one and send it out. But, I don't know how to get an old cookie, change it, and send it back. Or even, get a cookie, *copy it*, send the copy back. What is stopping the browser from creating a second cookie with the same name? Also, I've seen various ways of setting cookies. For example, one using APR::Request::Cookie and another using Apache2::Cookie. Which should I use? I'm setting a cookie by doing: $r-err_headers_out-add (Set-Cookie = $cookie-as_string); where $cookie is of type APR::Request::Cookie. Is this strange? (I forgot what I read to come up with this...most other documents mention a bake method...) Ray
Re: Cookie questions
Hi John, John ORourke wrote: Cookie names are unique to a given domain (the domain which can optionally be explicitly set using $cookie-domain ) - if you write another cookie with the same name and domain and path it'll overwrite the previous one. Ah, thanks for this! I guess I had a bug somewhere and I was setting the cookie from two different files and the default path in both cases were different because I didn't explicitly state it. I've done that now, and as you said, only one appears in the browser. Thanks! $r-err_headers_out-add (Set-Cookie = $cookie-as_string); Fine, that's basically what the bake() method does. I made a subclass of APR::Request::Cookie which included some hacks - try these: I see. Thanks for the suggestion! I thought one was better than the other, but whatever gets the job done? Since duplicates aren't allowed, I guess I don't have to get the cookie, change the date, and send it. I can just send a new one with a negative or 0 date. Whether or not the cookie was there in the first place, the result is that there won't be one. Thanks! Ray
Re: Cookie questions
Hi bop, Thanks for the e-mail. I ended up doing a mix of both your suggestion and John's and it seems to work ok. Both of your suggestions were great; thank you! Ray Boysenberry Payne wrote: Oops, I forgot the some code: # to set $cookie = { -name = foo, -value = bar, -path = / }; my $data = []; push( @$cookie_data, Apache2::Cookie-new( $r, %{$cookie} ) ); foreach ( @$cookie_data ) { $_-bake( $r ); } # now to unset my $jar = Apache2::Cookie::Jar-new( $r ); my $cookies = $jar-cookies; if ( defined $cookies-{foo} ) { $cookie = { -name = foo, -value = bar, -path = /, -expires = 0 }; push( @$cookie_data, Apache2::Cookie-new( $r, %{$cookie} ) ); foreach ( @$cookie_data ) { $_-bake( $r ); } }
Re: Memory usage
Michael Peters wrote: Any links or discussion would be great. You really need to benchmark it for yourself using the version you are targetting and the OS. You can do it outside of apache and just have a simple Perl script that does nothing but sleep after it's created the large data structure you want. Then use something like top (or whatever the best tool on your OS is) to see how much memory it takes us. I'm not sure if the numbers reported are accurate, but if Unix/Linux is used, then you can run the program under valgrind or the Unix time command (with appropriate flags). I don't know the details of perl, but I have written various data structures such as hashes in Perl and then C and the C version takes a lot less memory. I'm sure there is overhead because the perl script is interpreted, but there is probably a lot more going on. If you want to see how much memory the data structure (alone) is using, perhaps you (Will) can write two versions of the script...one with and one without the data structure...take the difference, as reported by valgrind, time, or top and you'll get the space used by the data structure. Ray
Re: Can't install mod_perl
Hi Octavian, Octavian Rasnita wrote: Please tell me, have you succeeded to install mod_perl under a X86_64 machine? If yes, please advice what should I do. Yes, I have, and haven't noticed any problems. I installed Debian stable (AMD64 version): http://www.debian.org/ports/amd64/ . The installation was generally straight-forward, but I encounter other problems such as Adobe Flash not being available, etc. But as for Apache 2/mod_perl 2...things are fine. If you didn't, do you know if a 32 bit Linux OS can be installed under a 64 bit machine? Is it adviceable to do this for a production machine? I'm not an expert on this, but looked into this briefly as I was worried about the level of support. From asking around, it seems that you can install 32-bit Linux on a 64-bit machine, but of course, you lose all the benefits of the 64 bits (access to larger disks and more memory per process). As an example, when I purchased my 64-bit machine, I was given the option to have Windows XP 32-bit or Windows XP 64-bit pre-installed for me. So yes, I guess a 32-bit OS can be installed. In the end, I decided against it and have a 64-bit OS. Otherwise, I'm wasting the extra money if I'm not using the extra hardware. Back when I was deciding, software like OpenOffice was unavailable for 64-bits...that has since changed and now, I don't have many complaints other than minor things like Adobe Flash, etc. Good luck with your mod_perl problem...sorry I couldn't give advice related to it, but it seems others have already... Ray
Re: First time being here, Need Big help here!
Xin, I have run Apache with Debian and I do recommend (if it's not too late) to uninstall Apache 1.3 and modperl 1 before installing Apache 2.x and modperl 2. They seem to install in different directories, but if you're not too attached to the old version, it'll save you headaches later (i.e., finding files, etc.) Ray Foo JH wrote: Don't understand what you mean. To rephrase myself: Apache 1.3 uses modperl 1 Apache 2.0 and 2.2 uses modperl 2 Does this help? [EMAIL PROTECTED] wrote: In the sentence Do note that modperl1 is that mod_perl 1.x or is that an extra 'el'? i assume mod_perl 2 works with apache 2.x On Mon, 09 Jul 2007 11:11:13 +0800 [EMAIL PROTECTED] wrote: I doubt. Apache2 is a major overhaul. You're better off installing apache2 or 2.2 from scratch. Do note that modperl1 is not compatible with apache 2
Re: modperl2 + apache2.2 unable to restart
Hi, Foo JH wrote: What's the actual error from the error_log? Below shows apache shutting and and restarting...and failed. [Thu Jun 14 17:30:19 2007] [notice] Parent: Received restart signal -- Restarting the server. [Thu Jun 14 17:30:19 2007] [notice] Child 5780: Exit event signaled. Child process is ending. [Thu Jun 14 17:30:20 2007] [notice] Apache/2.2.4 (Win32) mod_apreq2-20051231/2.6.0-dev mod_perl/2.0.3 Perl/v5.8.8 configured -- resuming normal operations I'm actually new to both Apache and mod_perl (a few weeks!), but if I were in your situation, one thing I would try is to remove apreq2 and mod_perl and try starting Apache 2.2 without them. I'd even re-install Apache 2.2 or try running with an empty httpd.conf... But, just random guessing here...even if they don't work, their error logs might prove useful. Ray
Re: End of file found error
Hi Joe, Joe Schaefer wrote: Anything here looks suspicious? Yes. Your code behaves as if CGI.pm was being used by Mason instead of apreq. When that happens, CGI.pm steals the post data, and apreq sees nothing but an End of File situation. If I were you, I'd double-check how you configured Mason to select apreq instead of CGI.pm. That's probably where the bug lies. Thanks for the tip! Yes, I finally found the problem. Indeed, it was because of how I configured Mason -- by default, it uses CGI.pm... No wonder the word CGI didn't appear in any of my configuration files when I was grepping... Unrelated to modperl, but in case a Mason user sees the same problem as me, adding this line to httpd.conf will do it: PerlSetVar MasonArgsMethod 'mod_perl' Now, I can see the number of parameters sent and can access the uploaded file fine. That's a lot of time spent for a single line... :-) Thanks for the help and the suggestion...that definitely helped me narrow things down! Ray
Re: End of file found error for file uploading
Hi Joe, Joe Schaefer wrote: with a form using the post method and an enctype of multipart/form-data. In my browser, I am getting a single message: End of file found. That is, the single line. What's happening is that $req-upload calls $req-body, and that is die'ing with the End of file found error. What browser are you using, and what version of apreq? Oh! I see. After I read your message, I tried other browsers and while all browsers could be wrong, I got the same error. First, I was using Iceweasel 2.0.0.3 and then I tried the Gnome Web Browser (Epiphany) 2.14.3 and even Elinks 0.11.X, all running on Debian and the same machine that the server is on (I'm testing locally). apreq2 is version 2.08.4 on Debian stable (testing seems to have a 2.08.5...). Any suggestions on how I can resolve the problem? Could there be something wrong in the server set-up, etc.? As I said, it's all running on a test machine (i.e., the web server isn't live on the Internet) so perhaps I didn't set it up correctly? Thank you for your reply! Ray
Re: End of file found error
Hi Joe, Joe Schaefer wrote: running on a test machine (i.e., the web server isn't live on the Internet) so perhaps I didn't set it up correctly? I really don't know, it could be the parser is just misbehaving on your particular html form. What you can do to further investigate is something like this: my $upload = eval { $req-upload(foo) }; if ($@) { $upload = [EMAIL PROTECTED]upload(foo); # won't die this time } ... and try to see where the form data is getting lost. For some reason, I am doubting my own HTML skills...or perhaps I've been staring at this for so long, the screen is getting blurry :-) . Anything here looks suspicious? test1.html: form action=http://localhost/~user/test2.html; method=post enctype=multipart/form-data name=mai nform input type=file name=filename / input type=text width=10 name=keyword / button type=submitSubmit/button button type=resetClear/button /form test2.html: %args $filename $keyword /%args %perl print $filename, br /; print $keyword, br /; my $req = Apache2::Request - new ($r); my @params = $req - param (); print scalar (@params), \nbr /\n; /%perl % #my $upload = $req-upload ('filename'); % There's some Mason in there, but basically, both $filename and $keyword print out ok (well, the filename), so it doesn't seem like any part of the form is lost. scalar (@params) is 0, though...which makes me think I'm doing something wrong. Shouldn't it be 2? And of course, if I move the commented line up, I get the End of file found error... As much as I'd like to be like other newbies and blame either apreq2 or the browser and say one of them is buggy :-) ...I'm more inclined to believe that since other people use it, it must be something that I'm doing wrong. If I remove the file input, and just leave the text box, then I still get the error. So, it isn't because of the file uploading... (I've changed the Subject to reflect this...) Perhaps it's what I'm doing with Mason? Ray PS: I don't mean to put you on the spot, Joe, for replying to me initially (which I am thankful for!). Of course, if anyone else can give me their ideas, I'd appreciate it, too!