Re: Fruitbasket and Server-Side Perl (Was: FruitBasket Criteria Down)

  • From: Veli-Pekka Tätilä <vtatila@xxxxxxxxxxxxxxxxxxxx>
  • To: programmingblind@xxxxxxxxxxxxx
  • Date: Sat, 13 Oct 2007 12:32:15 +0300

Hi Octavian,
As far as easy databases go, you could have used SQlLite, theoretically
speaking. Saying:

ppm i DBD-SQLite

installs both the database and its DBD driver. 0 configuration needed.
By the way, what I ment by idiomatic, in the other threadd, was if you
made Perl look like Perl rather than some other language, because of
better readability. One thing I personally dislike is watering down Perl
to make it easier to read, or more like some other language out there. I
do know you don't use the English module much, but recall reading
tutorials which don't even let you know what the short variable names
are. not that I'd be really worried, though, I just asked out of
curiosity. Here's a quote from perlsyn to demonstrate:

Quote:
Here's how a C programmer might code up a particular algorithm in Perl:

    for (my $i = 0; $i < @ary1; $i++) {
        for (my $j = 0; $j < @ary2; $j++) {
            if ($ary1[$i] > $ary2[$j]) {
                last; # can't go to outer :-(
            }
            $ary1[$i] += $ary2[$j];
        }
        # this is where that last takes me
    }

Whereas here's how a Perl programmer more comfortable with the idiom
might do it:

    OUTER: for my $wid (@ary1) {
    INNER:   for my $jet (@ary2) {
                next OUTER if $wid > $jet;
                $wid += $jet;
             }
          }

See how much easier this is? It's cleaner, safer, and faster. It's
cleaner because it's less noisy. It's safer because if code gets added
between the inner and outer loops later on, the new code won't be
accidentally executed. The "next" explicitly iterates the other loop
rather than merely terminating the inner one. And it's faster because
Perl executes a "foreach" statement more rapidly than it would the
equivalent "for" loop.
End quote.

Hope this helps.

-- 
With kind regards Veli-Pekka Tätilä (vtatila@xxxxxxxxxxxxxxxxxxxx)
Accessibility, game music, synthesizers and programming:
http://www.student.oulu.fi/~vtatila

Octavian Rasnita wrote:
> 
> Hi,
> 
> Ok, I've sent you to your personal address a rar file with 4 files; 2 are 2
> versions of the FruitBasket CGI version made in perl, one is a version that
> manually prints the HTML code that need to be created, and one prints the
> same thing, but uses the CGI module functions.
> 
> The other 2 files, in the "commented" dir, are the same files, but
> commented. Please add them all 4 in the same archive.
> 
> Well, now I think I will also add a fifth file that describes them a a
> little.
> 
> The perl code would have been very simple, but the hardest part was to store
> the list of all the fruits in a hidden field, then to restore them after the
> form is submitted, because I didn't want to store them on the server.
> It would have been much more simple if I'd put the program store them on the
> server as most of the server side programs need to do anyway, but the
> problem is that the target directory must have had the necessary
> permissions, or if I would have wanted to store them in a database I would
> have needed to specify the database connection, and the program wouldn't be
> able to run out of the box.
__________
View the list's information and change your settings at 
//www.freelists.org/list/programmingblind

Other related posts: