Testing my CGI
I’m using WWW::Mechanize for testing my CGI. I’m having trouble with the $mech-tick Here’s my code : ok($mech-form_name('cdr_format'),getting form cdr_format); print pAllFields = . $mech-value('pAllFields') . \n; 219- ok($mech-tick('pAllFields',1), 'Setting checkbox to native CDR format'); 220- ok($mech-tick('pAllFields’,0), 'Setting checkbox to native CDR format’); Here’s a snippet of the html : div id='myForm' form name='cdr_format' method='POST' action='file_admin.cgi' input type='hidden' name='rm' value='process_cdr_format' input type='hidden' name='CGISESSID' value='ec4c3463d5a7f9d04d2924968413f240' input type='hidden' name='cdr_format' value='1' table border='0' cellpadding='3' cellspacing='0' width='100%' tr td class='fieldLabel' width='60%' We would like the files in native CDR format: /td td class='field' input type='checkbox' class='checkbox' name='pAllFields' value='1' /td /tr When I execute I get this : ok 40 - getting form cdr_format Use of uninitialized value in concatenation (.) or string at ./test_cportal.pl line 218. pAllFields = not ok 41 - Setting checkbox to native CDR format # Failed test 'Setting checkbox to native CDR format' # at ./test_cportal.pl line 219. not ok 42 - Setting checkbox to native CDR format # Failed test 'Setting checkbox to native CDR format' # at ./test_cportal.pl line 220. Here’s the documentation from WWW::Mechanize $mech-tick( $name, $value [, $set] ) Ticks the first checkbox that has both the name and value associated with it on the current form. Dies if there is no named check box for that value. Passing in a false value as the third optional argument will cause the checkbox to be unticked.
Re: Testing my CGI
Look at the source code for the module. The 'tick' method just uses a bare 'return' on success, which means it's going to fail an ok() test regardless of whether or not it works. You may also want to look at Test::WWW::Mechanize. chrs, john. On Tue, Nov 4, 2014 at 7:30 AM, Patton, Billy N billy.pat...@h3net.com wrote: I’m using WWW::Mechanize for testing my CGI. I’m having trouble with the $mech-tick Here’s my code : ok($mech-form_name('cdr_format'),getting form cdr_format); print pAllFields = . $mech-value('pAllFields') . \n; 219- ok($mech-tick('pAllFields',1), 'Setting checkbox to native CDR format'); 220- ok($mech-tick('pAllFields’,0), 'Setting checkbox to native CDR format’); Here’s a snippet of the html : div id='myForm' form name='cdr_format' method='POST' action='file_admin.cgi' input type='hidden' name='rm' value='process_cdr_format' input type='hidden' name='CGISESSID' value='ec4c3463d5a7f9d04d2924968413f240' input type='hidden' name='cdr_format' value='1' table border='0' cellpadding='3' cellspacing='0' width='100%' tr td class='fieldLabel' width='60%' We would like the files in native CDR format: /td td class='field' input type='checkbox' class='checkbox' name='pAllFields' value='1' /td /tr When I execute I get this : ok 40 - getting form cdr_format Use of uninitialized value in concatenation (.) or string at ./test_cportal.pl line 218. pAllFields = not ok 41 - Setting checkbox to native CDR format # Failed test 'Setting checkbox to native CDR format' # at ./test_cportal.pl line 219. not ok 42 - Setting checkbox to native CDR format # Failed test 'Setting checkbox to native CDR format' # at ./test_cportal.pl line 220. Here’s the documentation from WWW::Mechanize $mech-tick( $name, $value [, $set] ) Ticks the first checkbox that has both the name and value associated with it on the current form. Dies if there is no named check box for that value. Passing in a false value as the third optional argument will cause the checkbox to be unticked. -- To unsubscribe, e-mail: beginners-cgi-unsubscr...@perl.org For additional commands, e-mail: beginners-cgi-h...@perl.org http://learn.perl.org/
Re: Testing an array for a match
Lou Hernsen wrote: Hallo Hello, I have an array @Treasures and I want to match anywhere in it for /:1:2:3:/ can I if (@Treasures =~ /:1:2:3:/){} or do i have to change (@Treasures to $Treasures and then $Treasures = @Treasures ; if ($Treasures =~ /:1:2:3:/){} if ( grep /:1:2:3:/, @Treasures ) { John -- Perl isn't a toolbox, but a small machine shop where you can special-order certain sorts of tools at low cost and in short order.-- Larry Wall -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Testing an array for a match
Hallo I have an array @Treasures and I want to match anywhere in it for /:1:2:3:/ can I if (@Treasures =~ /:1:2:3:/){} or do i have to change (@Treasures to $Treasures and then $Treasures = @Treasures ; if ($Treasures =~ /:1:2:3:/){} Just thought I'd ask first, I have to take mother in law to Dr. so I don't have time to test right now... I'll check email in a few hours... thanks Lou -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: php testing in my pc
POST TO THE DAMN PHP NEWSGROUP NOT THIS ONE! Daniel Hurtado Brenner [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hi friends: I use activeperl for for run and testing my cgi script in my PC. It's fine. Well... if i want to run and testing my PHP script and my Msql in my PC... what can i use? Thanks Daniel, from Peru -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: php testing in my pc
Please bottom post Charlie somerville wrote: POST TO THE DAMN PHP NEWSGROUP NOT THIS ONE! There are certainly more polite ways to indicate that a poster's question is off topic for a particular group... http://danconia.org Daniel Hurtado Brenner [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hi friends: I use activeperl for for run and testing my cgi script in my PC. It's fine. Well... if i want to run and testing my PHP script and my Msql in my PC... what can i use? Thanks Daniel, from Peru -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Beta Testing a Robot
Casey West wrote: I'm beta-testing a robot that searches Google when new questions are posed to the beginners' lists. I have no idea if it will be useful. :-) I'm going to watch it closely and hope it is. I'll remove it if I find that it does a bad job. Casey West Hi Casey, I'm getting in on this sorta late, but here's my $0.02 worth: I don't mind getting the bot responses. I guess I may be in a minority on this subject though. One thing I do see is a fairly broad spectrum search that sometimes shoots pretty wide of the mark. There are a couple branches to this, in my view: 1. The search seems to respond to boilerplate with equal or greater weight than to the meat of the question. I se the same problem with the perldoc -q implementation on my computer. I've got some thoughts on approachesw to this, but I'll defer them to later, because they are pretty speculative. 2. There may be benefit to using a prioritized search pattern with the significant content of the search string. I have been working on an archive manager for my record of this list [actually a generalized mailbox archive manager, and here is the approach I took. I actually had three search options: Precise phrase [case-insensitive], all words, and any words. The current search pattern seem to be more of an all words search. It might help to narrow that down to demand matches on mutliple words. Within my all words serach, I also used a priority queue system for ordering response by significance. Here I scan the file keeping a count of total matches found, and ensuring that each word was matched at least once: Note that each entry in the hash pointed to by $found_in, and loaded by iterative calls to this routine has a 'count' element. input: $regexes--anonymous array of search strings $file_key--anonymous array of message sequences numbers $files--anonymous hash of filenames, keyed by the above $file_keys $found_in--anonympous hash to be loaded with filenames, keys, and counts sub seek_all_words_in_file { my ($regexes, $file_key, $files, $found_in) = @_; my $file = $files-{$file_key}; open IN, $file or die Could not open $file $!; my $matchcount = {}; $matchcount-{$_} = 0 foreach @$regexes; my $line; $line = IN until $line and $line eq \x0A; # This gets me past a header section of the file I'm scanning my $total_count; while (defined ($line = IN)) { foreach my $regex (@$regexes) { # get match counts per line of each regex if (my $line_match_count = () = $line =~ /$regex/gi) { $matchcount-{$regex} += $line_match_count; } } } my $matched_all = 1; for (@$regexes) { $matched_all = 0 if not $matchcount-{$_}; # filters if any words are missing } return if not $matched_all; my $count; $count += $matchcount-{$_} for @$regexes; $found_in-{$file_key}-{filename} = $file if not $found_in-{$file_key}; $found_in-{$file_key}-{count} = $count; } The calling function uses the above scanning routine thusly: ... while (my $file_key = shift @$file_keys) { seek_all_words_in_file($regexes, $file_key, $message_files, $found_in); } display_search_results($found_in, $search_dialog); ... handing it off to the following sub. Keep an eye on the hash pointed to by $best_bets, since that is the actual priority queue mechanism: sub display_search_results { my ($found_in, $search_dialog) = @_; our $message_viewer; our $message_list; my $best_bets = {}; foreach my $file_key (keys %$found_in) { my $file = $found_in-{$file_key}; my $line_count = $file-{count}; $best_bets-{$line_count} = [] if not $best_bets-{$line_count}; push @{$best_bets-{$line_count}}, $file_key; } $message_list-delete('all'); my $match_count = 0; foreach my $priority_level (sort {$b = $a} keys %$best_bets) { foreach my $file (sort {$b = $a} @{$best_bets-{$priority_level}}) { my $details = get_message_info($file); add_message_to_tree($file, $details, $message_list, $file) } } set_viewer_status('sort', 'none'); } Of course this still somewhat lacks subtlety. For one thing there is no weighting for the balance of search words in the file being searched. It might be better to give extra points for files that had all words in roughly equal quantity. Between precise phrase and all words is also another standard, that I hadn't really tried to explore. That would be words in order'. Something like this might be best with the record separator set to a period, so that it would scan text on a sentence-by-sentence basis, looking for all words in the same order as the search phrase, even if intermingled with other text. Unlike the above, I haven't built or tested this but a general algorithm for the regex might be: my $regex = quotemeta shift @search_words; regex .= .*$word while my $word = quotemeta shift @search_words; Whcih should render a regex that will match any string
Re: Beta Testing a Robot
It was Wednesday, December 03, 2003 when Casey West took the soap box, saying: : I'm beta-testing a robot that searches Google when new questions are : posed to the beginners' lists. I have no idea if it will be useful. : :-) I should like to make an important note. This bot is not intended to deter people from answering questions. Indeed, the goal of this list is still to give detailed, useful answers to questions. Specific answers that really help people. This robot is intended as a First Response Service, something that can help the questioner between the time they ask a question and the time they receive a good answer, from a human. My goal is that the archives from this list and others, and the web itself will be of further assistance, perhaps even adding a spark of creativity to some code or thought process. Therefore I hope this robot will bring that information a small step closer to the list. So please, keep answering those questions. The robot doesn't do such a great job at answering questions, only guesses at where the technical information might be, which is still a very useful service as far as I can see. Finally, the subject lines from the robot have been altered to show what it really is, a First Response System. Think of a person in cardiac arrest. First Response does some very general, well tested attempts at saving the patient. Sometimes they're successful, but the patient still needs to see the doctor, maybe even ER. That's what we're here for. :-) Casey West PS: For all who asked, I'll show the source code in due course. I don't quite understand why the first response is sent back to the list rather than just the OP though? Using your analogy it seems like the first response is *also* trying to save the doctors at the same time, which would seem to get in their way. Another concern is that the response comes from your address, or at least uses your name, which will eventually (though maybe the subject will stem this, since it just went in) cause me to ignore all posts from Casey West which would be a bad thing. Personally I use the list through SMTP and don't have a thread/filter option for about half the time I am reading it (don't worry early next year I intend to write a web mail client that I can use that will do these things ;-)) which means the automated messages get in the way more than they help *me*. I do like the idea of sending help back to the OP, and I appreciate your time and efforts as admin of the list(s), just throwing out my $.02 http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Beta Testing a Robot
Casey West wrote: I'm beta-testing a robot that searches Google when new questions are posed to the beginners' lists. I have no idea if it will be useful. :-) I'm going to watch it closely and hope it is. I'll remove it if I find that it does a bad job. Casey West This does seem like a good idea, but for some of us who can not access the web from work, this just makes it worse. I signed up for the list, to see others questions and responses, as well as post my questions and receive answers through email. With the bot giving responses with links that I can not access, it just makes it more frustrating, since others will not feel the need to respond since the bot gave links. If it wasnt for the corp nazis here, I would love this bot! Chris -- --- Just Your Friendly Neighborhood _SPIDEY_ - The information contained in this message may be privileged, confidential, and protected from disclosure. If the reader of this message is not the intended recipient, or any employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that any dissemination, distribution, or copying of this communication is strictly prohibited. If you have received this communication in error, please notify us immediately by replying to the message and deleting it from your computer. Thank you. Paychex, Inc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Beta Testing a Robot
It was Wednesday, December 03, 2003 when Casey West took the soap box, saying: : I'm beta-testing a robot that searches Google when new questions are : posed to the beginners' lists. I have no idea if it will be useful. : :-) I should like to make an important note. This bot is not intended to deter people from answering questions. Indeed, the goal of this list is still to give detailed, useful answers to questions. Specific answers that really help people. This robot is intended as a First Response Service, something that can help the questioner between the time they ask a question and the time they receive a good answer, from a human. My goal is that the archives from this list and others, and the web itself will be of further assistance, perhaps even adding a spark of creativity to some code or thought process. Therefore I hope this robot will bring that information a small step closer to the list. So please, keep answering those questions. The robot doesn't do such a great job at answering questions, only guesses at where the technical information might be, which is still a very useful service as far as I can see. Finally, the subject lines from the robot have been altered to show what it really is, a First Response System. Think of a person in cardiac arrest. First Response does some very general, well tested attempts at saving the patient. Sometimes they're successful, but the patient still needs to see the doctor, maybe even ER. That's what we're here for. :-) Casey West PS: For all who asked, I'll show the source code in due course. -- I have traveled the length and breadth of this country and talked with the best people, and I can assure you that data processing is a fad that won't last out the year. -- The editor in charge of business books for Prentice Hall, 1957 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Beta Testing a Robot
It was Thursday, December 04, 2003 when Wiggins d Anconia took the soap box, saying: : : : It was Wednesday, December 03, 2003 when Casey West took the soap box, : saying: : : I'm beta-testing a robot that searches Google when new questions are : : posed to the beginners' lists. I have no idea if it will be useful. : : :-) : : I should like to make an important note. This bot is not intended to : deter people from answering questions. Indeed, the goal of this list is : still to give detailed, useful answers to questions. Specific answers : that really help people. : : I don't quite understand why the first response is sent back to the list : rather than just the OP though? Using your analogy it seems like the : first response is *also* trying to save the doctors at the same time, : which would seem to get in their way. Another concern is that the : response comes from your address, or at least uses your name, which will : eventually (though maybe the subject will stem this, since it just went : in) cause me to ignore all posts from Casey West which would be a bad : thing. : : Personally I use the list through SMTP and don't have a thread/filter : option for about half the time I am reading it (don't worry early next : year I intend to write a web mail client that I can use that will do : these things ;-)) which means the automated messages get in the way more : than they help *me*. : : I do like the idea of sending help back to the OP, and I appreciate your : time and efforts as admin of the list(s), just throwing out my $.02 Thanks for the input, it's most valuable. That's the point of testing, after all. :-) Casey West -- When a cat is dropped, it always lands on its feet; when toast is dropped, it always lands with the buttered side facing down. I propose to strap buttered toast to the back of a cat; the two will hover, spinning inches above the ground. With a giant buttered-cat array, we could power entire metropolitan areas. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Beta Testing a Robot
My $0.02 on this: While it may be a worthwhile personal pursuit to write a script that provides relevant results from google based on the text of someone's email/news posting/etc, I don't think this is the forum for it. These are very busy lists to start with and this essentially will result in doubling the 'new' traffic to the list with information that is irrelevant to anyone but the original poster. The irrelevancy of the auto responder will increase when faced with questions by folks that are so far off that they're not even asking the right question to begin with(seems to be somewhat common in these groups). For these people, investigative questioning is the only correct response and an autoresponder (with a lot of text - read: information overload) will only confuse them more. If anything, the response should go directly to the poster, not to the list. IE: Your question has been posted to the XXX List, while you're waiting for someone to respond, try out these links from google.com that may or may not be relevant to your query: 1. link Google Desc ... 10. link Google Desc Also, googling should be the first resort of any technical person. I think the list FAQs should be updated in Section 2, Question 9 'Other Tips Before Posting To The List' with something like: _1._ Try to google.com with your question first! Google has extremely relevant search results and may preclude asking your question to the list. Tossing his copper in the pot, Matt Shaw Technical Architect xwave, An Aliant Company Bus: 506-389-4641 (Mctn) Bus: 506-444-9639 (Fred) Cel: 506-863-8949 [EMAIL PROTECTED] -Original Message- From: Casey West [mailto:[EMAIL PROTECTED] Sent: Wednesday, December 03, 2003 3:41 PM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: Beta Testing a Robot I'm beta-testing a robot that searches Google when new questions are posed to the beginners' lists. I have no idea if it will be useful. :-) I'm going to watch it closely and hope it is. I'll remove it if I find that it does a bad job. Casey West -- Good Idea: Kissing a loved one. Bad Idea: Kissing a total stranger. -- 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: Beta Testing a Robot
It was Wednesday, December 03, 2003 when Casey West took the soap box, saying: : I'm beta-testing a robot that searches Google when new questions are : posed to the beginners' lists. I have no idea if it will be useful. : :-) : : I'm going to watch it closely and hope it is. I'll remove it if I : find that it does a bad job. Thank you for your timely and useful responses, they're under consideration. Until a decision has been reached (and re-coded), the bot will be temporarily suspended. Casey West -- I'm just glad it'll be Clark Gable who's falling on his face and not Gary Cooper. -- Gary Cooper on his decision not to take the leading role in Gone With The Wind. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Beta Testing a Robot
Casey, I would like to chime in on the side of sending the search results directly to the poster. In most cases, the poster is at the mercy of the search engine they choose. Whereas, you have the advantage of knowing where to search. Please do not abandon this work. A digest -- to which, one may subscribe -- of this activity may also prove useful in the long run to the lurkers like myself. Thanks for the cool and interesting approach to getting an answer out to the questioner. Chuck [EMAIL PROTECTED] wrote: It was Wednesday, December 03, 2003 when Casey West took the soap box, saying: : I'm beta-testing a robot that searches Google when new questions are : posed to the beginners' lists. I have no idea if it will be useful. : :-) : : I'm going to watch it closely and hope it is. I'll remove it if I : find that it does a bad job. Thank you for your timely and useful responses, they're under consideration. Until a decision has been reached (and re-coded), the bot will be temporarily suspended. Casey West -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
[REBUILT] Re: Beta Testing a Robot
It was Thursday, December 04, 2003 when Chuck Fox took the soap box, saying: : Casey, : : I would like to chime in on the side of sending the search results : directly to the poster. In most cases, the poster is at the mercy of : the search engine they choose. Whereas, you have the advantage of : knowing where to search. Please do not abandon this work. A digest -- : to which, one may subscribe -- of this activity may also prove useful in : the long run to the lurkers like myself. Fear not! I've received a lot of good feedback, and here are the results. http://bfr.caseywest.com The First Response System is no longer going to the mailing list. It's also not going to the OP. If you notice, the new footer on all the list postings points to a redirection URL. http://learn.perl.org/first-response You can subscribe to the RSS feed. http://bfr.caseywest.com/index.rdf Your can search the site and read all the archives if you like, as well. We'll see how this approach works out. I've yet to get the FAQ updated, but I will. : Thanks for the cool and interesting approach to getting an answer out to : the questioner. I hope it works. The goal is to be helpful, after all. :-) : -- : To unsubscribe, e-mail: [EMAIL PROTECTED] : For additional commands, e-mail: [EMAIL PROTECTED] : http://learn.perl.org/ http://learn.perl.org/first-response Aah, there it is. Casey West -- Usenet is like Tetris for people who still remember how to read. -- Button from the Computer Museum, Boston, MA -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
php testing in my pc
Hi friends: I use activeperl for for run and testing my cgi script in my PC. It's fine. Well... if i want to run and testing my PHP script and my Msql in my PC... what can i use? Thanks Daniel, from Peru -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: php testing in my pc
On Monday, Nov 10, 2003, at 07:48 US/Pacific, Daniel Hurtado Brenner wrote: Hi friends: I use activeperl for for run and testing my cgi script in my PC. It's fine. Well... if i want to run and testing my PHP script and my Msql in my PC... what can i use? you will need to install the php executable. you might want to check one of the traditional php web-sites about the gory details. ciao drieux --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: php testing in my pc
There are several programs which can set up a web-based programming environment for you. In Windows my favorite is PHPTriad, which sets up PHP, PERL, MySQL/PHPMyAdmin for you. - Doug, from the USA Quoting Daniel Hurtado Brenner [EMAIL PROTECTED]: Hi friends: I use activeperl for for run and testing my cgi script in my PC. It's fine. Well... if i want to run and testing my PHP script and my Msql in my PC... what can i use? Thanks Daniel, from Peru -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - This mail sent through IMP: http://horde.org/imp/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Testing.....
testing CGI without webserver on NT?
On Windows2000. I have an html page that calls a perl script in a form but IE does not execute the script but rather asks that it be downloaded. Perl is installed in E:\foo\Perl and not the usual C:\Perl directory. could this have something to do with it? Thanks, Al -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: testing CGI without webserver on NT?
HI -- You need to execute the perl script. Change the permissions in IIS to execute BUT make sure that you don't have write set as well;) Mike -Original Message- From: Alaric J. Hammell Sent: Mon 6/10/2002 4:09 PM To: [EMAIL PROTECTED] Cc: Subject: testing CGI without webserver on NT? On Windows2000. I have an html page that calls a perl script in a form but IE does not execute the script but rather asks that it be downloaded. Perl is installed in E:\foo\Perl and not the usual C:\Perl directory. could this have something to do with it? Thanks, Al -- 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]
Sorry, just Testing...
testing anyone?
louie miranda (axishift.ath.cx) -- Security Is A Series Of Well-Defined Steps chmod -R 0 / ; and smile :) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Testing for truth
I'm a newbie myself, but if I understand you correctly, you just need to check if the SQL query returns a defined value? simply: if (!defined($sql)){ do something... } else { do something else } or: print sorry if !defined($sql); print Yippee if defined($sql); Joni -Original Message- From: Daniel Falkenberg [mailto:[EMAIL PROTECTED]] Sent: 23 July 2001 00:42 To: '[EMAIL PROTECTED]' Subject: Testing for truth List, I would like to be able to test my SQL query for truth. To do this I would like to be able to do a SELECT query and if the colunm contains nothing I would like my script to be able to return and tell me this. As an example. if I do a SELECT statement as follows SELECT test FROM support WHERE unique_id ='1234' If test = '(NOTHING)' print Sorry the search retuned no results please search again. elsif test = 'hello world' print here are the results for your search. I can do this exact same thing if I am searching with numeric values such as data and time. But can't seem to return a true statement if the column contains some words? Any ideas? Thanks in advance. Regards, Daniel Falkenberg -- 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]
Testing for truth
List, I would like to be able to test my SQL query for truth. To do this I would like to be able to do a SELECT query and if the colunm contains nothing I would like my script to be able to return and tell me this. As an example. if I do a SELECT statement as follows SELECT test FROM support WHERE unique_id ='1234' If test = '(NOTHING)' print Sorry the search retuned no results please search again. elsif test = 'hello world' print here are the results for your search. I can do this exact same thing if I am searching with numeric values such as data and time. But can't seem to return a true statement if the column contains some words? Any ideas? Thanks in advance. Regards, Daniel Falkenberg -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: testing for max size of file
Curtis Poe wrote: : That will only give the approximate filesize. $ENV{CONTENT_LENGTH} is the total :size of the : entity body. With 'multipart/form-data' (the enctype used with file uploading), the :entity bodies : size is even larger than normal. The more data sent (besides the file), the larger : $ENV{CONTENT_LENGTH} will be. : : Unless I am mistaken, CGI.pm does not track filesize data directly. If the POST :size (not file : size) is larger than what CGI.pm is allowed, then $query-cgi_error will contain the :text 413 : Request entity too large. That's right. Here's an extract from CGI.pm: $content_length = defined($ENV{'CONTENT_LENGTH'}) ? $ENV{'CONTENT_LENGTH'} : 0; ... METHOD: { # avoid unreasonably large postings if (($POST_MAX 0) ($content_length $POST_MAX)) { $self-cgi_error(413 Request entity too large); last METHOD; } So it's checking the CONTENT_LENGTH. There is, I believe, no other way to get the file size without actally measuring the uploaded file; but of course, the point of checking the size is to not let huge files get this far. So I think CONTENT_LENGTH, imperfect though it may be, is the only way to *prevent* a large file from getting on your system in the first place. -- tdk
Re: testing null strings for form field values
On Mon, 4 Jun 2001, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote, if ( $formdata{view_name} ne ) { $view = $formdata{view_name}; $viewtag = 1; } is there a special method for testing against a null string for a form field's value? i am using the above data, but it seems to always return with a value of 1 making me think that something is incorrect in my if test. the form itself does not have anything default value specified for view_name. Take a look at these one-liner examples. The string (nothing) indicates that no output is printed. 1% perl -le '$x; print 1 if $x ne ' (nothing) 2% perl -le '$x = undef; print 1 if $x ne ' (nothing) 3% perl -wle '$x = undef; print 1 if $x ne ' Use of uninitialized value at -e line 1. 4% perl -wle '$x = i am here; print 1 if $x ne ' 1 5% perl -we '$x = undef; print ($x)\n; Use of uninitialized value at -e line 1. () 6% perl -we '$x = ; print ($x)\n; () Number 2 is basically same with number 1 in that $x is undefined, except that $x variable in the number 2 is explicitly assigned. (Number 1 will also give you extra warning if you use -w). The line under number 3 is not an output of the code, it's a warning that will guide you what's wrong with the code. Undefined value is not the same as empty string (), but both are evaluated to false. If you use undefined variable anyway, it will be evaluated to empty (see no.5 and 6). Empty field is sent as undefined value and when you test it against with 'ne' operator, it evaluates to true because they're not equal. You need the defined() function to test whether the variable contains some defined value, and it will cover both and 0 if the test returns true. if (defined $var) { } If you need the value of the variable and you don't want then you need to test that too, if (defined $var and $var ne ) { } or if (defined $var and length $var) { } But if you rather want to test $var against true value, you can simply use, if ($var) { } Btw, did you use -w switch and use strict in your script? You really should. All those example codes above will bail out when you use strict. hth s.a.n -- Hasanuddin Tamir: [EMAIL PROTECTED] - Trabas: www.trabas.com
Re: testing null strings for form field values
Randal is of course right. I apologize for my extremely confusing and idiom riddled post. Randal L. Schwartz wrote: David == David Labatte [EMAIL PROTECTED] writes: David The why though is most likely that: undef ne '' That's not true. undef eq ''. Sorry I meant that statement in the english phrase sense not in the literal perl sense. I'll translate it from garbledslash.psudogeekese and never use that particularly poor and confusing dialect here again: undef is undef, '' is ''. Occasionally perl will care. Best to treat them differently until your comfortable with their differences. Not even close to what I actually said, but it's what I meant. I guess I was expecting the reader to somehow divine my actual thoughts. David What I usually do if I have code that expects an empty string David instead of an undef is append an empty string onto it when I read David the cgi.pm value into it. David $formdata{view_name} = $query-param('view_name') . ''; David That way undefined form elements have a consistent value and David it's easy to just send them back out to the user if I have to David without mangling them for display. This is voodoo programming. You must've had some problem that this appeared to solve at some point, but it isn't needed for what you are answering here, so I don't know how that can help. Sorry your right, this is bad programming and way beyond the scope of what was asked in this question and should not have been mentioned. Since I've badly explained myself already, I'll waste a little more time and say it's a useful idiom to force the cgi.pm return value to a true '' so the differences between it and undef don't bite you unexpectedly. I'll try to be more on topic with my responses from now on. undef acts for all intents and purposes the same as an empty string. If you have warnings on, you'll get messages when you use it as an empty string, but you would have got a message on that first concatenate as well. Very true, and sorry this post is not very clear, lucid or representative of what I was thinking. Not the best of contributions on my part, and I'm sorry for anyone I've confused. I will improve. I promise :) Thank you Randal for being there giving me a standard to improve to. -- Perl, because 600 billion oysters can't be wrong Canadian Consulting Services' pet perl hacker David Labatte [EMAIL PROTECTED]