Re: Flushing output buffer under mod_perl
Ibrahim Dawud [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Since mod_perl wraps my entire code into a handler subroutine behind the scenes, I figured out how to access the apache API from a normal cgi script. Hence, the following example appears to be working under mod_perl2: snip / With my more complicated example (listed below), I get mixed results. Sometimes it works, sometimes I get segmentation faults, and sometimes I get the following error in my Apache error_log which I don't understand: $r-rflush can't be called before the response phase at /html/perl/test.pl line 107 The complete code is as follows: snip / sub newstatus { my ($s) = @_; print EOT ; script language=JavaScript1.2!-- newstatus($s); //--/script EOT $r-rflush; } Ick. It looks to me like this should work. Since the only thing you are using the Apache request object for is to flush the buffer, you might want to try Apache-request-rflush instead of holding a reference to the object. Though if what you have is breaking, it probably won't work. I suggest taking this to the mod_perl mailing list, I'm sure they would want to know about it. Make sure you give them system and environment info... Todd W. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: htaccess question
Bill Stephenson [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On Aug 17, 2005, at 11:03 AM, zentara wrote: On Mon, 15 Aug 2005 16:29:54 -0500, [EMAIL PROTECTED] (Bill Stephenson) wrote: On Aug 12, 2005, at 2:06 AM, David Dorward wrote: snip / How do I point this at a perl cgi script to process the logon? If I'm understanding your question correctly... The server is going to automatically process the login with a popup, beyond the control of any cgi script. So you are NOT going to bypass the server's auth mechanism, and replace it with a Perl script. Ok, I thought maybe the AuthType might have a way to use a perl script to process logons, but it really doesn't matter now, the client has decided not to try and fight this issue (big sigh of relief), which I tried to point out was actually an interface issue, and go with what works. But if it was possible it would be interesting to play with ;) With mod_perl you can override the default apache handler that handles Basic auth. mod_perl lets you override _any_ phase of the request cycle. It effectively turns your web server in to an application server. For an example of how to do basic auth in mod_perl, see http://search.cpan.org/~mschout/Apache-AuthCookie-3.08/lib/Apache/AuthCookie.pm. For more information on mod_perl, see http://perl.apache.org/. trwww -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: changing action with appended key/value pairs in a POST
Scott R. Godin [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I have a multi-stage cgi I'm currently working on, and as I progress thru the stages (the form uses POST not GET for reasons of data-size) I was hoping to be able to simply add ?step=confirm or ?step=finish to the form action ( -action=$htmlform{action}?step=confirm, ... ) However it's not working, and I'm getting the distinct impression that when the action is a POST, CGI.pm ignores anything WRT the uri request line... Is this true? You could refer to the CGI.pm docs, specifically the part about mixing POST and URL parameters: http://search.cpan.org/~lds/CGI.pm-3.11/CGI.pm#MIXING_POST_AND_URL_PARAMETERS if ($q-url_param('step') eq 'confirm' ) { ... } or put the step parameter in a hidden field in the html form: input type=hidden name=step value=confirm / You may also want to check out CGI::Application, it makes quick work of what you are trying to do. Todd W. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: quote problem and mysql
Andrew Kennard [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hi all snip / my $Vals; for ( my $i=1;$i=32;$i++ ) { $Vals.='?,'; } chop $Vals; Ugh. $vals = join(', ', ('?') x 32 ); Ideally, you should have your data in an array, then: my $sql = INSERT INTO table VALUES (${ \join(', ', map('?', @data)) }); $dbh-do( $sql, undef, @data ); Todd W. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: How to plug memory leak?
Zentara [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On Mon, 20 Jun 2005 21:46:52 -0600, [EMAIL PROTECTED] (Siegfried Heintze) wrote: What about the memory used by threads? Do I have to join with a thread to recover its memory? snip / To destroy a thread, you must make sure you make the thread goes to the end of it's code block, then join it. snip / Compliment: This is some of the most beautiful code I've seen on p.b.cgi. Question: But I have a question about the code down in the main thread below: ### sub work{ $|++; while(1){ if($shash{'die'} == 1){ goto END }; if ( $shash{'go'} == 1 ){ foreach my $num (1..100){ $shash{'data'} = $num; select(undef,undef,undef, .1); if($shash{'go'} == 0){last} if($shash{'die'} == 1){ goto END }; } $shash{'go'} = 0; #turn off self before returning }else { sleep 1 } } END: } ###3 What if the thread is sleeping when the code gets right... To destroy the thread from main, $shash{'die'} = 1; ### HERE ### $thread-join; Didnt you say: When you make a thread, you pass it a subroutine to run. The thread WILL NOT join unless the thread goes to the end of that subroutine. Agian, beautifuly simple code. Thanks, Todd W. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: image manipulation (scaling)
Ingo Weiss [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hi all, I need have my CGI scale images on the server, and I was wondering whether there is a standard perl module that can do that (and possibly other image manipulation tasks). I am looking for one that: - is easy to understand and use - is likely to be already installed on the server or so well known that my hosting provider is likely to agree to install it for me. If by scaling you mean making thumbnails, I once did this simple CGI program that lets the user upload a jpeg file, uses Image::GD::Thumbnail to resize the image, then sends it back to the user: #!/usr/bin/perl use warnings; use strict; use CGI::Carp qw(fatalsToBrowser warningsToBrowser); use CGI; my $q = CGI-new(); use GD; use Image::GD::Thumbnail; if ( $q-param ) { my $fh = $q-upload('theImage'); # Load your source image my $srcImage = GD::Image-newFromJpeg( $fh ); # Create the thumbnail from it, where the biggest side is 50 px my($thumb,$x,$y) = Image::GD::Thumbnail::create($srcImage, $q-param('theSize')); print $q-header(-type = 'image/jpeg'); binmode( STDOUT ); print $thumb-jpeg; } else { print $q-header(-type = 'text/html'); print $q-start_html( -title = 'jp(e)g to thumbnail converter' ); print $q-h1( 'jp(e)g to thumbnail converter' ); print $q-br( { width = '75%' } ); print $q-div( 'jp(e)g to thumbnail converter' ); print $q-div( 'nbsp;' ); print $q-div( 'Enter A jp(e)g File Name: ' ); print $q-start_multipart_form(); print $q-div( 'Size in pixels you wish the longest side to be: ', $q-textfield( -name = 'theSize', -size = 3, -default = '100', -override = 1, ) ); print $q-div( 'nbsp;' ); print $q-div( $q-filefield('theImage', '', 50) ); print $q-div( 'nbsp;' ); print $q-table( $q-Tr( $q-td( $q-submit ), $q-td( $q-reset ) ) ); print $q-endform; print $q-end_html; } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: What exactly does $| = 1; do?
Robert [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I have seen in a few scripts now, including some of the articles that Mr. Schwartz has written. I have read it does something with the buffers but on a more technical level what is that? Robert Along with the other explinations, consider an example: [EMAIL PROTECTED] trwww]$ perl use warnings; use strict; foreach my $i ( 1 .. 5 ) { print($i, '...'); sleep( 1 ); } print( \n ); $| = 1; sleep( 1 ); foreach my $i ( 1 .. 5 ) { print($i, '...'); sleep( 1 ); } print( \n ); ^D 1...2...3...4...5... 1...2...3...4...5... The first line is all printed out at once. The second line prints '1...' then waits a second then prints '2...' and so on. Todd W. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Storing Form Data without submitting it.
Wiggins D Anconia [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hi everybody, I' m not sure this is the right list to ask this kind of question but I don't know where else. We are using html forms to insert and update news articles (texts) stored in a mysql database. Ever so often one of our journalists forgets to press the submit button or his computer crashes and everything written so far is lost. Is it possible to built something like an autosave function that submits the form data automatically every couple of minutes and updates the database entry? Any hint's where to look up these kind of things? It is sort of the right place :-)... Because this is a client side action (at least what triggers it) you are probably going to want to look to javascript. I believe you can setup timers in javascript that will trigger actions, that will be the hard part, the easy part is the action that is triggered is just a standard submit of the form, then the server side script would just store the info and reprint the form with the fields filled in the same, which I am assuming you can do. As a suggestion I would add (at least) two features, 1) a clock that displays a form element that is continually updated with the number of seconds left until the next save (as you will have to reload the page and there is nothing your journalist will hate more than being in the middle of a great thought and having his page reload on him) which brings me to... 2) have a reset clock button, so that if the user *is* paying attention they can reset it so that the refresh doesn't happen... Which brings me to not refreshing since I know you will ask. Presumably the javascript could build a request and submit it in a separate object (possibly in a popup window) which would provide all of the data from the form, the response would be that the form data has been saved and then wait a second or two and close the window automatically, then theoretically you wouldn't have to refresh the page. But now we are getting much more into the Javascript land where I am not nearly as strong. Overkill at this point, but you can set up and RPC server on the web server and use a javascript RPC client to send the data to the server. I use RPC::XML as the server (Apache::RPC::Server) and jsolait as the client. The initialization JavaScript looks like: // rpc server endpoint var rpcAddr = 'http://favorites.waveright.homeip.net/rpcservice'; // stores rpc server connection try{ var xmlrpc = importModule(jsolait.xmlrpc); rpcServer = new xmlrpc.ServerProxy(rpcAddr, new Array(), true); }catch(e){ reportRpcError( e ); } and then you can say stuff like: // calls rename method on rpc server try { rv = rpcServer.favorites.rename( activeNode.type, activeNode.id, newValue ); }catch(e){ reportRpcError( e ); } rename() is a perl subroutine compiled into the web server when it is started. Your call would look something like: rv = rpcServer.contentManager.updateArticle( articleID, articleBody ); What happens here is the RPC client formats the function call into XML, then uses a http library that comes with your browser to make a http request to the RPC server. The server reads the XML sent in the reqest, and calls the perl function with the arguments specified. The return value of the function is formatted as XML by the server and sent back to the client. The client reads the XML response and converts the return value to a JavaScript datatype. This does away with things like the page reloading pointed out in another reply. The RPC call to the server is totally transparent to the user. The browser must support DOM level 2. IE 6, NN 7.1 and firebird all work great. If you would like to see an example of RPC in action check out: http://favorites.waveright.homeip.net/ Like I said, a bit of overkill for what you mentioned, but if you implement something like this then you can do things like build batch article updating and so fourth in a snap. If you know ahead of time that you will want to interface with the same data in two different ways ( for example, from both a command line program and a CGI program ), then RPC or SOAP is the way to go. Todd W. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: REMOTE_USER
Colin Johnstone [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Thank You for answering my post. Im only a perl newbie, I read something that gave me the idea that this would be handled by cgi thats why I posted here. So what your saying is:- by virtue of the fact that a user has been authenticated, if they try to access a protected page. Then the server will decide whether to serve that page or not. All we have to do is use .htaccess files and/or entries in httpd.conf. Colin Right. Your web server knows that the page that was requested is a simple document as opposed to a CGI application. It also knows that this document has no way of validating the credentials submitted via basic authentication, so the server does the verification for you. The REMOTE_USER variable is used to identify the person/request who has received verification. With static documents the server simply sends the document to the http client. The REMOTE_USER environment variable is no use to your web page so it isnt even set. But with CGI programs, you can use the REMOTE_USER variable to find out who logged in and do things like record click trails and have online shopping carts. Note this is not how _I_ would do it, but it is a perfectly viable method. Todd W. Bob Showalter [EMAIL PROTECTED] 12/11/2003 11:52 PM To: Colin Johnstone/Australia/Contr/[EMAIL PROTECTED], [EMAIL PROTECTED] cc: Subject:RE: REMOTE_USER Colin Johnstone wrote: Gidday All, We are running AIX on an IBM HTTP server with IHS. We are serving static HTML pages. Some of these pages are to be protected. OK. That's the job of the web server, so you need to configure it to protect those pages. With Apache, you use .htaccess files and/or entries in httpd.conf. I assume IHS has something similar. I assume I place the restricted pages in a particular directory and then protect that directory. Once authenticated a user should be able to view protected pages without logging in again for the duration of the session. Right. Under basic authentication, the browser caches the credentials and supplies them automatically for any 401 responses. What does this have to do with Perl? I understand that once a user is authenticated their (userId) email address will be stored in the environment variable REMOTE_USER for access by cgi-scripts. The environment variables are set by the web server prior to invoking the CGI script. Now what I don't understand is how from a static HTML page can I check this REMOTE_USER variable automatically. Of course the first time they visit a page in the protected directory they will be prompted for their username and password, but then what? You don't check it from static pages. The web server checks the authentication credentials (from the HTTP request, not the environment), and either serves or doesn't serve the static page. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: HTML headers with CGI.pm
David Gilden [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hello, Having some issues with cgi.pm Here is my PERL: ### # Start HTML OUT ### print header; print start_html( -title = $title ); print qq|meta http-equiv=Pragma content=no-cache\n|; and here is the output: ?xml version=1.0 encoding=iso-8859-1? !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd; html xmlns=http://www.w3.org/1999/xhtml; lang=en-US xml:lang=en-USheadtitleJake#39;s Guestbook entries 0 - 10/title /headbodymeta http-equiv=Pragma content=no-cache First you print the output of the start_html() method, and then a html tag named 'meta'. Its doing exactly what you told it to. How do I move the Pragam inside the head and it also looks like I have two doctype definitions. Thanks for any suggestions. You do not have two doctype definitions. Read the specs on dtds. As far as the meta tag, try reading the CGI.pm documentation: perldoc -m CGI heres an excerpt: print $query-start_html(-title='Secrets of the Pyramids', -author='[EMAIL PROTECTED]', -base='true', -target='_blank', -meta={'keywords'='pharaoh secret mummy', 'copyright'='copyright 1996 King Tut'}, -style={'src'='/styles/style1.css'}, -BGCOLOR='blue'); After running this your next question will be how to create a http-equiv meta tag. Again, read the docs. Todd W. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Help wanted regading approch for displaying live scores
Parvez Mohamed [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hi, I am building a application in which i need to display live stock market prices with out the user presing the refresh button. Its similer to live game scores. snip / i need to refresh only some fields not the whole page I can use floating frames for this but i dont think its good solution First you set up an RPC server to get the stock quotes. I like RPC::XML. Then you use an RPC client in the browser to fetch quotes and update fields in the html document using DHTML. I just did a web project that uses an RPC client in the browser: http://waveright.homeip.net/products/FavoritesAnywhere.html Todd W. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
online favorites project
xposted to: perl.beginners, perl.beginners.cgi I've wrote a web based program to store favorites online. I work on quite a few computers each week between home, work, and school and its something I've wanted for awhile. The program is account based so others can use it. It is free to use. The home page is at: http://waveright.homeip.net/products/FavoritesAnywhere.html It works on IE 6 and NN 7.1. It should work on any Gecko 1.4 based browser. Technically, it should work on anything that supports DOM Level 2, cookies, and JavaScript. If you find it useful, please tell your friends about it. You can get support at the link below. It is free software. I have a stack of features I want to add to it. I would like to invite other developers to work on it with me. The server side logic is written in mod_perl. The pages are generated with Template::Toolkit. The menu is generated with XSLT. The DHTML does alot of DOM work, and the menu options talk to the server using RPC. The server uses RPC::XML, and the client uses jsolait. The idea is simple, so even beginners could contribute. User and developer questions/suggestions can be posted at: http://waveright.homeip.net/tools/phpBB2/index.php?c=5 Thanks eveyone, Todd W. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Still Not sure if I agree with myself.
Drieux [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On Friday, Sep 12, 2003, at 18:54 US/Pacific, Todd W. wrote: [..] I dont think you can call that a closure yet. You would have to be defining subroutines that refer to lexical variables outside of the subroutine or something along those lines: [EMAIL PROTECTED] trwww]$ perl { my $dog = 'spot'; sub dogsName { my $pooch = $dog; return(my dog is $pooch); } } [..] Mea Kulpa! What Was I Thinking? I just did the perldoc -q closure but. hum... { package Foo::Bar use base qw/Foo/; ... } Would seem to meet the minimum requirement, since the 'use base' there deals with the @ISA for that package name space... The block is still not a closure, because @ISA must be a package global for the inhertance mechanism to work its magic. use base qw/Foo/; is semantically the same as: our(@ISA) = qw/Foo/; As a matter of fact, declaring @ISA as a lexical will effectively disable inheritance for a given module: [EMAIL PROTECTED] trwww]$ perl use warnings; use strict; use CGI; { package Foo; our(@ISA) = qw/CGI/; } # inerited class method print Foo-escapeHTML('foobar'), \n; Ctrl-D fooamp;bar and then: [EMAIL PROTECTED] trwww]$ perl use warnings; use strict; use CGI; { package Foo; my(@ISA) = qw/CGI/; } print Foo-escapeHTML('foobar'), \n; Ctrl-D Can't locate object method escapeHTML via package Foo at - line 10. Beacuse of @ISA being lexically declared, it can't inherit from other modules. And remember, for a logical scope to be called a closure, you have to be dealing with lexical values. But I think the part that scares me is that my $action = { doDaemon = sub { . }, ... }; would get us into the same 'space'? Not if you declare $action to have its own file or block scope. You would have to define an accessor to access $action. I'm not sure I really want to actually create YA_CGI_AppServer, although, I fear that I am in dire meandering towards that sort of 'can one create a general enough solution' Since, well, uh, one of my doodles is about passing in a reference to an object, and such things ... Since the basic 'shell' of a CGI script still looks like: snip CGI parser example / make_header_and_send($page_type, $page); so that of course yearns to be in a module, rather than as something one would cut and paste into each new CGI script... But looking at your diagramme, I think I can see why you are pointing towards a YA_CGI_AppServer If you have a reuseable component that dispatches other components you can call it an application server, for some definitions of an application server. Todd W. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Still Not sure if I agree with myself.
Drieux [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] This discussion goes along with the one you are having with fliptop. One of my first question is - why the 'closure' eg: { package FOO; } Or is that simply to make 'clear' that outside of the Closure it is still package 'main'??? I dont think you can call that a closure yet. You would have to be defining subroutines that refer to lexical variables outside of the subroutine or something along those lines: [EMAIL PROTECTED] trwww]$ perl { my $dog = 'spot'; sub dogsName { my $pooch = $dog; return(my dog is $pooch); } } print dogsName(), \n; print Share your dog '$dog' with me\n; Ctrl-D my dog is spot Share your dog '' with me Only the sub dogsName() knows the value of $dog. NOW the braces are a closure for the lexical. Before that they just made up a block. The last line of code above explodes with strict. So, when you do your: { package FOO; } And you define lexicals in there, only functions internal to the block have access to the lexical. If you put each class in its own file, you get the same behavior because files have thier own scope. In OO terms, this is called 'private static members' snip / Which leads me to my second set of question, as a general habit I tend to make 'private-ish' methods with the _ prefix such as sub _some_private_method { } is there some 'general access' mechanism by which one can ask for the LIST of all methods that an 'object' CanDo??? Or should one have a 'register_of_parser_methods' approach that one can query? I followed your link ( that I affectionately snipped ), but it was a couple days ago. If your hell-bent on writing YA_CGI_AppServer, then check out how the currently existing ones handle dispatching. CGI::Application is an excellent example and easy to follow because its simple. There are others, too. I like to write my own application server components because it is fun to see one evolve from an empty text file to set of directories worthy of CVS: http://waveright.homeip.net/~trwww/api.gif But sometimes its funner to pretend everything is a jigsaw puzzle. Making CGI::Application, CGI::Session, Class::DBI, and Template::Toolkit work together transparently has been interesting. Perhaps one day it will be done =0). Todd W. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: form submission DoS
Kevin Pfeiffer [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] [a little OT in a general way...] This was sent to another list today and I am wondering what the answer might be... The following data was submitted from the Frequently Asked Questions Form snip / My thought is to add some simple field validity checking to the form-to-mail script. Not perfect, but would at least stop the mail (until the bad guy writes a cleverer script). But what about the submission process? How to stop someone from scripting 2,000+ form submissions? (If at all) If its your ( Apache ) server, or you have a friendly sysadmin, you can use Apache::SpeedLimit. It blocks calls from a client if they start getting greedy with your services. Todd W. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: passing an argument to a subroutine
B. Fongo [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hello An argument passed to a subroutine returns wrong value. Code example: @x = (1..5); $x = @x; here, $x gets the number of elements in @x showValue ($x); # or showValue (\$x); sub showValue { my $forwarded = @_; $forwarded gets the number of elements in @_ print $forwarded; # print ${$forwarded}; } In both cases, the script prints out 1. What is going on here? What do you expect to happen? What _is_ happening is exactly what is supposed to. Todd W. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: cookies with CGI and IE7
Andrew Brosnan [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Anyone having trouble setting or retrieving cookies with CGI.pm and IE7? I'm doing: my $cookie = $q-cookie( -name= 'session', -value = $session, -expires = '3h', print $q-header( -cookie = $cookie); I got some feedback that the cookie wasn't working in IE7. I've never heard of IE7. I just checked the internet explorer home page and it has a big 'ol 6 right in the top middle of the page. http://www.microsoft.com/windows/ie/default.asp Todd W. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: debugger
Awarsd [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hi, my web host does not offer a perl debugger and told me to use use CGI::Carp qw(warningsToBrowser fatalsToBrowser); Is that it, how should i print the errors?? When you have a question about a module, please read the module's documentation before posting here: http://search.cpan.org/author/LDS/CGI.pm-2.99/CGI/Carp.pm You are looking for the sections labeled: MAKING PERL ERRORS APPEAR IN THE BROWSER WINDOW and MAKING WARNINGS APPEAR AS HTML COMMENTS Todd W. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Mail::Send question
Camilo Gonzalez [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Definitely avoid this if possible, there are numerous mail message modules, one of them is bound to provide what you need. Why is sendmail held in such low regard by this group? Most on this list will agree sendmail is one of the Internet's first killer apps. But because interfacing directly with the sendmail binary can be confusing and bug prone there are modules on the CPAN that use sendmail as the transport mechanism. These modules abstract sendmail's intricacies from the user, providing a simple API to send mail. Therefore, modules are the preferred way to send mail from a perl program. Todd W. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: AS400 and Comsoft
Dennis Stout [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Somebody is not using a very friendly mailinglist client. It's pretending this is a newsgroup, which is tricking things up... Are you talking about me? I'm the one that replied to your op. I have outlook express account that points to nntp.perl.org. There is software that emails list members all of my posts to the news server, and this software also takes all emails sent to the list and posts them to the news server. So, all of the lists on perl.org are mailing lists AND newsgroups. Sure its possible. Just go to CPAN, install the interfaces to each type of storage system, and then in your program connect to each data source. You said you will be connecting to 3 data sources, so you will have 3 objects representing each connection. 3? I don't know math very well but.. You will be connecting to x data sources, so you will have x objects reperesenting each connection. Better? It's your project, not mine. There are already interfaces to the most common SQL databases. Theres also a perl LDAP interface. You may have to build your own interfaces for the Comsoft and AS/400 applications if you must access them with perl. The way you do this is by creating perl wrappers to the C api that comes with your data stores. I don't know how to program in C. Maybe now is a good time to learn, since my deadline is hte 22nd of August :) So many jokes... so little time ;0) I would create a custom object that stores each object as a property. This will make managing the connection objects easier. If it were up to me, I would be investing heavily in Vaseline corporation because I know exactly where this new ticket system is going to end up The mind reels. Todd W. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: AS/400 and Comsoft systems
Dennis Stout [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Heyuck Heyuck. So I'm told I need to write a simple database to handle ticketing information for customers when they call. Now I'm told I have to make it talk to 2 more SQL servers, an Oracle server, an LDAP server, a Comsoft system, and an AS/400. Is this possible with Perl or am I needing to find a solution deeper rooted then a CGI script? Sure its possible. Just go to CPAN, install the interfaces to each type of storage system, and then in your program connect to each data source. You said you will be connecting to 3 data sources, so you will have 3 objects representing each connection. There are already interfaces to the most common SQL databases. Theres also a perl LDAP interface. You may have to build your own interfaces for the Comsoft and AS/400 applications if you must access them with perl. The way you do this is by creating perl wrappers to the C api that comes with your data stores. see: perldoc perlxstut I would create a custom object that stores each object as a property. This will make managing the connection objects easier. Todd W. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: return(bless $rant, $class) || Fwd: PHP vs Perl
Drieux [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] So you will forgive me if I do not opt to jump onto the new band wagon that 'all developers' should wax their surfBoards, because foo is the Next Big Wave that will solve all problems end to end, as I will counter, your counter to my counter below... Remember, I am of the this AND that philosophy, so you can walk, run, dirt bike, or staddle two bandwagons at the same time if you like, and, as long as you get where you are going, I will agree that it was done correctly. { not that I am being merely contrarian... } you? nah!!! =0) [..] p4: given that hacking in perl does not require MVC as a design pattern, but one can learn the hard way to support it We have AxKit, but I wouldnt like to call it the canonical perl I so love the fact that slowly but surely the One True Perl Orthodoxy is finally being able to create the canonical perl yourPhraseHere. insertThingiePooHere I meant canonical as in the ususal way one accomplishes something rather than the perl god's doctrine on how to accomplish something As we perlers know, when we ask the gods how to do something, they start uttering, as if in tounges, timtoady!, something we perl diciples understand as, theres more than one way to do it. Also, I hope youre reading, as qoted that, I WOULDN'T like to call it the canonical perl MVC pattern... MVC pattern. Most familiar with it probably would though. ASP.NET has MVC with its code behind concept. Im not aware of any other MVC based platforms right off. Todd W -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: return(bless $rant, $class) || Fwd: PHP vs Perl
Drieux [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Todd either Paused for more MountainDew or had a Moment: [..] Those last two paragraphs were total rant, and I probably have no idea what I'm talking about, but they are getting posted anyway ;0) [..] I would like be so totally opposed to your position if it were not for most of the dark horror of where I so totally agree with you But First off - COOL RANT! I was hoping that _some_ day I could string a few sentences together as well as you do =0) Unfortunately, I dont think I have accomplished it yet!!! p0: let us not confused science, technology and VOODOO. Computer Science is wonderful for providing a theoretical intellectual underpinning to hashing algorithms, while a specific instance of that as a technology of course is perl's 'hash' data structure, the actual 'coolness' of course lies in using it in strange and arcane ways that border on Voodoo. bless this ref... I agree, as long as you agree that the more one understands the CS theory, the less voodoo there is in the implementation. p2: I am very nervous that folks are noticing that at present PHP is not supportive of MVC as a design pattern - and that may be a limiting factor - but as you have also noted, given the gaggelation of globulated together 'stuff' - eg: ASP+HTML+SQL - this means that there are still great employment opportunities refactoring that stuff into maintainable code. So we should support the spread of PHP without MVC as a basis for more work refactoring the code??? return unless defined( $ref ); I think that most languages are supportive of MVC as a design pattern, but each language's advocates and tutorial designers are not. All intro tutorials are rightfully simple and stratightforward example usages of a technology. But as we have been discussing, most developers, it seems, take this as the end-all be-all of app development technology, declare themselves proficient, and consider the tutorial reason enough to add to the expert column on one's resume. This leads right to the next comment: p4: given that hacking in perl does not require MVC as a design pattern, but one can learn the hard way to support it We have AxKit, but I wouldnt like to call it the canonical perl MVC pattern. Most familiar with it probably would though. ASP.NET has MVC with its code behind concept. Im not aware of any other MVC based platforms right off. Todd W. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to run script Perl automatically???
Lielie Meimei [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hello...Would u help me to solve thi prob: How to run a perl script automatic when web server start running ??? Because i want to run a perl script without run it manually in konsole.. This is not the easiest thing in the workd to do, but luckily perl makes hard things possible. If you are using a mod_perl enabled apache, there is a step-by-step guideline of several different scenarios for starting programs from an apache process: http://perl.apache.org/docs/1.0/guide/performance.html#Forking_and_Executing _Subprocesses_from_mod_perl Todd W. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Trying to block out BGCOLOR
[EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I'm making something, and need to block out BGCOLOR attribute. The problem is, the BGCOLOR could be with or without quotation marks. This is the code I used: $article =~ s/ bgcolor=(?)(.*?)(?)//gi Here is how I would do it, using SAX with a helper module called XML::SAX::Machines: package Skip::BGCOLOR; use strict; use XML::SAX::Base; use vars qw/@ISA/; @ISA = qw/XML::SAX::Base/; sub start_element { my($self, $el) = @_; for my $property ( keys %{ $el-{Attributes} } ) { if ($property =~ /BGCOLOR$/i ) { delete( ${ $el-{Attributes} }{$property} ); } } $self-SUPER::start_element( $el ); # forward the element downstream } sub xml_decl { } 1; package main; use strict; use XML::SAX::Machines qw/:all/; my($pipeline) = Pipeline( 'Skip::BGCOLOR' = \*STDOUT ); $pipeline-parse_string( join('', DATA) ); print(\n); __DATA__ html head titleNo BGCOLORs/title /head body bgcolor=red h1 bgcolor=whiteNo BGCOLORs/h1 hr width=75% / div BGCOLOR=blueNo BGCOLORs/div /body /html Much cleaner and it guarantees to not fudge up your markup. Todd W. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: CGI.pm strange results
Zentara [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On Mon, 3 Mar 2003 16:07:26 -0500, [EMAIL PROTECTED] (Todd Wade) wrote: Zentara [EMAIL PROTECTED] wrote in message You might want to try assigning a variable name to param(quantity) first, before you set up the table. I don't know why, but sometimes the scripts don't like it any other way. I've run into this type of thing before, and just take the easy way out, and assign a variable. This is not true at all. Well what ever the reason is, it has worked that way sometimes for me. When you start deeply nesting and quoting in tables and here documents, Perl will sometimes fail to interpolate unless you force the value into a variable. I guess I havn't learned the trick yet. Sorry, not true at all. There really is no trick. Interpolating is interpolating is interpolating. When you start ?deeply nesting? and quoting in tables and here documents, perl will never fail to interpolate unless you don't understand the syntax and semantics of injecting values into literals. Perhaps you could post an example, because I am very curious. But taking an educated guess at the problem you are having, I would say you are talking about getting CGI.pm's param() function to return in a string. my( $string ) = you ordered $q-param('quantity') foobars\n; The quoting mechanism knows nothing about evaluating expressions. That's what concatenation is for: my( $string ) = you ordered . $q-param('quantity') . foobars\n; Todd W. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: php like behavior for my perl CGI
f'ups rearranged [EMAIL PROTECTED] wadet]$ perl sub box { return('img src=p.gif height='.$_[0].' width='.$_[1].''); } print eot; table tr td${\box(5,10)}/td td${\box(7,10)}/td /tr /table eot Ctrl-D table tr tdimg src=p.gif height=5 width=10/td tdimg src=p.gif height=7 width=10/td /tr /table see: [EMAIL PROTECTED] wadet]$ perldoc perlref Peter Kappus [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] ... Aha! This is exactly the kind of solution I was looking for. I guess what I'm doing here is passing a reference to a subroutine call? \box(5,10) and then turning it into a scalar? ${} Almost. In most contexts in perl, a { } construct is a BLOCK, and all code in between the braces will be evaluated. So for our example, we call box then return a reference to box()'s return value. if a reference logically follows a $ in an interpolated string, the the reference will be dereferenced. Hence the desired results. If (for some reason) we were passing a reference to the subroutine, it ( may ) look like this: [EMAIL PROTECTED] wadet]$ perl sub box { return('img src=p.gif height='.$_[0][0].' width='.$_[0][1].''); } print eot; table tr td${\box( [5,10] )}/td td${\box( [7,10] )}/td /tr /table eot Ctrl-D table tr tdimg src=p.gif height=5 width=10/td tdimg src=p.gif height=7 width=10/td /tr /table and if you want to go OO: package My::Img; sub new { my($class, %params) = @_; return( bless( { %params }, $class ) ); } sub box { my($self) = shift(); return('img src=p.gif height='.$self-{height}.' width='.$self-{width}.''); } package main; print eot; table tr td${\ My::Img-new(height =5, width = 10)-box() }/td td${\ My::Img-new(height =10, width = 5)-box() }/td /tr /table eot Ctrl-D table tr tdimg src=p.gif height=5 width=10/td tdimg src=p.gif height=10 width=5/td /tr /table but thats just silly ;0) dont forget: see: [EMAIL PROTECTED] wadet]$ perldoc perlref and for a real good time, check out [EMAIL PROTECTED] wadet]$ perldoc perllol Quite ingenious. While I'm sure I'll regret it later (and curse your good name as I'm wishing I'd taken the time to learn Mason or HTML::Template) this seems like a great quick fix for the time being. And it never hurts to learn a few new tricks! Unfortunately theres nothing there I came up with on my own, and yes, new tricks are always good for the 'ol grab bag =0). HTH, Todd W. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: php like behavior for my perl CGI
Peter Kappus [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED] ... Thanks to all who have responded to my rather vague request. Indeed, I should clarify a bit what I'm looking for. Because I'm extremely lazy, I'd like to use certain formatting shortcuts in my HTML. In a given document, I might have 15 different spacer gifs of different sizes to aid in precise formatting that would look something like this: img src=spacer.gif height=50 width=10/ no offense, but when I see blank gifs, I see anti-lazy... In PHP, or ASP, for example, I would write a spacer(height,width) function and call it in my block of HTML like so: ?spacer(50,10)? which would create and send the image tag for me. I'd like, in perl, to do the following: printeob; table border=0 TR TD?spacer(10,50)?/TD /TR /TABLE eob Ideally, I would overload the print function so that it would search for statements between ?? delimeters and execute them. Of course, I could also say: my $spacer1=spacer(10,50); my $spacer2=spacer(50,100); printeof; table TR TD$spacer1/TD TDsome stuff/TD TD$spacer2/TD /TR /TABLE eof but it seems like there should be an easier way with fewer keystrokes and fewer intermediate variables. Well, you can save yourself a bundle of keystrokes and use a templating system and cascading stylesheets, but heres a quick fix: [wadet@ecg-redhat wadet]$ perl sub box { return('img src=p.gif height='.$_[0].' width='.$_[1].''); } print eot; table tr td${\box(5,10)}/td td${\box(7,10)}/td /tr /table eot Ctrl-D table tr tdimg src=p.gif height=5 width=10/td tdimg src=p.gif height=7 width=10/td /tr /table see: [wadet@ecg-redhat wadet]$ perldoc perlref Perhaps, my dream is completely quixotic, but so far, it seems like the kind of thing that must be very easy if only I knew the right trick... You need to understand references and the underlying semantics of computer data structures. Set theory dosent hurt either. Then you dont even have to think about it. Like breathing. Also the only real benefit I've seen of PHP over perl-cgi is the ease with which one can mix HTML and code (Naturally, most web architects will jump at the opportunity to tell you why this is a very bad idea but it often makes life easier for small projects) Ive never had a project stay small for long. I hope this clarifies things a bit. If not..I guess I'll just need to do a few extra keystrokes :) Many thanks! no prob, Todd W. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Confusion on @array vs $array[] vs $array
Fliptop [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... On Wed, 18 Dec 2002 at 13:49, kevin christopher opined: kc:Hope this doesn't further belabor the issue, but just to put my kc:two cents in, Perl syntactic rules for prefixing $, @, % are kc:very consistent, IMHO: You just need to keep in mind the types of kc:the values/data types ultimately being expressed, and it should kc:become clearer. $ always prefixes scalars or references, @ kc:always prefixes lists, and % always prefixes associative arrays kc:(a.k.a hashes). kc: kc:@array is a list kc:$array[n] is a scalar/reference kc:%hash is a hash kc:$hash{'key'} is a scalar/reference kc:@$ref dereferences a reference to an array, accessing the array In kc:this case, print $ref; would give you a reference scalar, kc:something like ARRAY(0x4E3FB1C); print @$ref; would output the kc:actual array list. kc: kc:Also try @hash{keys %hash}, which returns a list of the hash's kc:values. i hope everyone realizes that all this will be changed in perl 6. here's a snippet from a slideshow by damian conway from the summer 2001: Access through...Perl 5 Perl 6 Array variable $foo[$idx] @foo[$idx] Array slice@foo[@idxs] @foo[@idxs] Hash variable $foo{$key} %foo{$key} Hash slice @foo{@keys} %foo{@keys} Scalar variable$foo$foo Array reference$foo-[$idx]$foo.[$n] Hash reference $foo-{$key}$foo.{$key} Code reference $foo-(@args) $foo.(@args) The dereferencing isnt going to be _that_ bad. Since a .[, .{, or .( after a string preceeded by a $ implies dereferencing, the . can be dispensed. From Exgenesis 2: http://www.perl.com/pub/a/2001/05/08/exegesis2.html Here's a handy conversion table: Access through... Perl 5 Perl 6 = == == Scalar variable $foo$foo Array variable $foo[$n]@foo[$n] Hash variable $foo{$k}%foo{$k} Array reference $foo-[$n] $foo[$n] (or $foo.[$n]) Hash reference $foo-{$k} $foo{$k} (or $foo.{$k}) Code reference $foo-(@a) $foo(@a) (or $foo.(@a)) Array slice @foo[@ns] @foo[@ns] Hash slice @foo{@ks} %foo{@ks}beautiful =0) Todd W. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Perl 6 (was: Re: Confusion on @array vs $array[] vs $array)
Fliptop [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... [reply cc'd to list] On Thu, 19 Dec 2002 at 06:23, Rob Richardson opined: RR:What is the advantage of these changes? RR:When is Perl 6 due out? RR:Do those links you provided describe all the differences we will see in RR:Perl 6? i'm no authority on perl 6, so i can't answer any of your questions. to keep up with what's happening, your best bet is to subscribe to one of the perl 6 mailing lists. you may want to start here: http://www.perl.org/support/mailing_lists.html -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Perl 6 (was: Re: Confusion on @array vs $array[] vs $array)
Fliptop [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... [reply cc'd to list] On Thu, 19 Dec 2002 at 06:23, Rob Richardson opined: RR:What is the advantage of these changes? RR:When is Perl 6 due out? RR:Do those links you provided describe all the differences we will see in RR:Perl 6? i'm no authority on perl 6, so i can't answer any of your questions. to keep up with what's happening, your best bet is to subscribe to one of the perl 6 mailing lists. you may want to start here: http://www.perl.org/support/mailing_lists.html Im no authority on perl 6 either, but if I wanted to dive in to in perl 6, Id start at: http://www.perl.com/pub/q/Article_Archive#Perl%206 specifically the apocalypses and the exgenesises (sp?). Theres enough reading there to keep you busy until a release version =0). Todd W. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: GD Graphs
Mikeblezien [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Hello, I am going to be working on a project, that will be utilizing the GD::Graphs module to create various graph reports. I was hoping that someone could point me to some good documentation or working examples of the uses of this module... of course I've been to CPAN, but was hoping to find more working examples of it's use. If you've used this module, would appreciate if you can direct me to some good docs and examples,... or if some one can recomend a better method of creating and working with graphs and Perl. I just borrowed a book from the library called: Programming Web Graphics With Perl GNU Software / Shawn P. Wallace that was a pretty exciting read. Re-reading it this weekend. Todd W. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: perl cgi security
Jim Lundeen [EMAIL PROTECTED] wrote in message news:3DBDA799.307DC69A;jimmyjames.net... nothing that will work on Linux box? perlcc works... see below. Admin-Stress wrote: Nice, but that will produce .exe, executable file for Windows :( --- David Simcik [EMAIL PROTECTED] wrote: See perl2exe.exe for details on converting scripts into executables. [trwww@devel_rh public_html]$ cat index.cgi #!/usr/bin/perl -w use strict; use CGI qw/:standard/; print header(); print start_html(); print h1('Hello Dynamic CGI Linux'); print div('Hello Dynamic CGI Linux!!!'); print div('I am:', `id -un`); print end_html();[trwww@devel_rh public_html]$ perlcc -o index.plx index.cgi [trwww@devel_rh public_html]$ ls -l total 1704 snip / -rwx--1 trwwwtrwww 219 Apr 14 2002 index.cgi -rwxrwxr-x1 trwwwtrwww 1707157 Oct 31 15:48 index.plx snip / [trwww@devel_rh public_html]$ ./index.plx Content-Type: text/html; charset=ISO-8859-1 ?xml version=1.0 encoding=utf-8? !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN SYSTEM http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd; html xmlns=http://www.w3.org/1999/xhtml; lang=en-US head titleUntitled Document/title /head body h1Hello Dynamic CGI Linux/h1 divHello Dynamic CGI Linux!!!/div divI am: trwww/div /body /html HTH Todd W. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]