Re: Can Perl be used to develop test scenarios?
On Wednesday, August 1, 2001, at 04:29 PM, beginners-digest- [EMAIL PROTECTED] wrote: Whilst this could be done in Perl, I don't think it has been, and I don't think it's a task for a beginner. I would take a look at comp.software.testing Point a browser at http://www.testingfaqs.org/t-gui.htm too, which has a list of gui testing tools. I picked up one of the intro to Xtreme Programming books, and one of their tenets is Decide what you want to do; write a test to see if you're doing that; write code to pass that test. Sure, it's common sense, but there's probably something to be said for doing it formally. 99% of the Perl I write is CGI stuff. I've thought about (but haven't done much research into) setting up some testing scripts that use, perhaps, LWP to fake form submission for CGI testing. It seems like it would be a fairly straightfoward task... Write a testing script, have it call a CGI and capture the error message or output that the CGI would be sending back to a browser. No real question here, just musing aloud. Anyone done anything similar? Any potential pitfalls? It seems that a basic framework for the testing suite could be written once, then modified for the number of fields, their types and names. Read that in, maybe from a hash, and you could develop the whole thing as a module maybe? Anything like this already exist?
Re: Converting Unix paths to windows
On Wednesday, June 27, 2001, at 08:59 AM, [EMAIL PROTECTED] wrote: Hi, I am writing a script to be used on Windows and many different flavors of Unix. I am looking for a good way to convert Unix paths to Windows. Any Ideas? Not exactly an answer to your question, but perhaps something that may be of use to you... The following cross platform snippet (found somewhere on the web, I believe) will return the path of where the script is running. if($0=~m#^(.*)\\#){ $cgidir = $1; } # win/dos elsif ($0=~m#^(.*)/# ){ $cgidir = $1; } # Unix else {`pwd` =~ /(.*)/; $cgidir = $1; } # Unix I'm guessing you could use it to find a base directory, and then do relative stuff from there. You may also be able to use its test blocks to flag whether or not you're on a windows box and construct your relative paths accordingly. There are probably other ways that platform can be determined, but TMTOWTDI seems to be a credo around here. Hope this helps.
Re: Noobie question
On Wednesday, June 13, 2001, at 12:05 PM, Ward, Stefan wrote: Does anyone have an example of a way to write a perl script that will go out hit a data base table, pull in a column for that table and use that column in a dropdown list? I know what to do once I get that variable selected by RTFriendlyM, but couldn't find a clear example of this. Gee, you get three responses with books to read, or URLs to visit, but nobody actually answering your question. Fucking typical. Excuse me. Ok. So you've read the manual, and you're doing your SELECT from the database. In many cases, I find myself getting both a value and a human readable text for my dropdown. For sake of argument, let's say your dropdown was a list of web pages, and the VALUE for each OPTION is the URL of the page. So my statements might go something like... my $sql = SELECT URL, Name FROM Links ORDER BY Name; my $sth = $dbh-prepare($sql) or die (Cannot prepare query $sql); my $sth-execute or die (Cannot execute query $sql); my @fields = ''; my $selectstatement = SELECT name='Link'; while (@fields = $sth-fetchrow_array) { $selectstatement .= OPTION value='$fields[0]'$fields[1]/OPTION ; } $selectstatement .= /SELECT; I hope this answer is more useful than that suggested by the others.
Re: help!
On Tuesday, June 5, 2001, at 07:37 AM, Randal L. Schwartz wrote: That's why I bring it up as a meta-topic. We've had to deal with the same thing on perlmonks.org Randal, no offence meant, but I was under the impression that the purpose of this list was to answer questions, and not say tell new users to RTFM. I admit, I was disappointed to see you active in this forum, because your answers to beginner questions on PerlMonks are the type that this list was supposed to be avoiding. I respect that you know an awful lot about Perl. That's fine and good. This forum is for people who don't have your expertise, and sometimes when they're looking for an answer to a question -- they'd really like to hear an answer to their question and not you don't want to do that -- read this web page.
looping over an array of hashes
First post, quick question: I've got an array of hashes that I'm defining the most basic way I can... my $gSeasonID; my @season_list = ''; while (@fields = $sth-fetchrow_array) { $gSeasonID = $fields[0]; $season_list[$gSeasonID]{number} = $fields[1]; $season_list[$gSeasonID]{title} = $fields[2]; $season_list[$gSeasonID]{active} = $fields[3]; } where @fields is coming from a DBI query. Essentially I have $season_list[1]{number} = 1; $season_list[1]{title} = 'Season One'; $season_list[1]{active} = 0; $season_list[2]{number} = 1; $season_list[2]{title} = 'Season Two'; $season_list[2]{active} = 1; That's fine, and it seems to be writing correctly. But I'd like to loop on my array index later to get back, say {title} from each season. Is there a clean way to do this with foreach or while? What I'd be looking for would be $season_list[$loop_season]{name}, if I were using a for loop with $loop_season as my index. Is there a way to do this with $_ or something and foreach so that I don't have to know the size of my array?