http://www.perlmonks.org?node_id=232774

rozallin has asked for the wisdom of the Perl Monks concerning the following question:

Hi Everyone,

I follow the USENET newsgroup alt.food.vegan for recipe ideas, making a .txt copy of any recipe I think might be interesting to use. Over the years, I've amassed quite a collection of these (well over a thousand), and it's becoming very difficult to organise them and find them. What I decided to do was create a searchable database of sorts, so I could search based on key ingredients, preparation time, number of servings, type of meal, etc. using a web browser based interface (so I can add features like measurement conversion charts, and print out recipes if I need to).

But like many ideas I come up with, it's one of these things in which I don't have the technical ability to implement it. At the moment I don't even know whether it would be better to use Perl or PHP/MySQL to do this. Size is not really a consideration, as I don't see it being made available online in the forseeable future, unless I put so much work into it that it seems a waste not to make it freely available, with the permission of course of those who posted the recipes in the first place. Neither is my ability (or lack of it) in both of the languages, as I'm willing to look upon it as a learning experience :)

Has anymonk ever created something of a similar vein, and if so which way did you approach this? Thanks in advance,
--
Rozallin J. Thompson
The Webmistress who doesn't hesitate to use strict;

  • Comment on "cook-ebook" - Should I use Perl or PHP/MySQL?

Replies are listed 'Best First'.
Re: "cook-ebook" - Should I use Perl or PHP/MySQL?
by davorg (Chancellor) on Feb 05, 2003 at 09:51 UTC

    I would have thought that Perl with MySQL would be your best choice, but then I'm a little biased because I've never seen the point of PHP.

    acme (who doesn't frequent PerlMonks any more) has over 100,000 recipes in his searchable database at http://astray.com/recipes/. Knowing him, it's probably implemented in Perl, MySQL and the Template Toolkit. I'm sure he'd be happy to share the code.

    --
    <http://www.dave.org.uk>

    "The first rule of Perl club is you do not talk about Perl club."
    -- Chip Salzenberg

Re: "cook-ebook" - Should I use Perl or PHP/MySQL?
by theorbtwo (Prior) on Feb 05, 2003 at 10:00 UTC

    As to PHP or Perl, the answer is to use the language that you're most comfortable writing it in. I suspect that's Perl.

    As to it being beyond your technical expertise, I think you're overestimating how hard it will be. Consider using text files in some sort of standardized format, rather then going full-out, and using a database.

    \

    Good luck with your project -- it sounds like a good one. Difficult enough to strech your skills, without being too difficult to be approachable. Most importantly, somthing you have actual use for.


    Warning: Unless otherwise stated, code is untested. Do not use without understanding. Code is posted in the hopes it is useful, but without warranty. All copyrights are relinquished into the public domain unless otherwise stated. I am not an angel. I am capable of error, and err on a fairly regular basis. If I made a mistake, please let me know (such as by replying to this node).

      I'm assume that you are planning some kind of web interface.

      I think that for most web based projects PHP is usually much simpler and the libraries you need are built in compared with perl where you would have to download and install them.

      PHP is built from the ground up for producing web pages. I find web based stuff usually takes a fraction of the time to do in PHP than perl.

      If you later decide to make the page public their are litterally hundreds of ISP's where your code will run without any alteration. A perl based solution would be A LOT MORE work.

      On the other hand if it's not web based then perl is a few million times better.

Re: "cook-ebook" - Should I use Perl or PHP/MySQL?
by castaway (Parson) on Feb 05, 2003 at 10:14 UTC
    Since I've no clue about PHP, I'd say use Perl :)
    If you're looking to find out about using Databases in Perl, without figuring out bigger stuff like MySQL, then try DBD::SQLite. Looking at a good tutorial about designing databases is also a good idea.

    On the other hand, if you don't then you can always just use flat files (CSV?), though that sounds like it might get a bit complicated with a lot of search-fields.

    C.

Re: "cook-ebook" - Should I use Perl or PHP/MySQL?
by broquaint (Abbot) on Feb 05, 2003 at 11:24 UTC
    If you're looking upon this opportunity as a learning experience then I would recommend going with Perl and your database of choice (which would appear to be MySQL in this case).

    I recommend Perl over PHP for several reasons

    • you have all the resources and community support of The Monastery
    • the available introduction literature is superb (assuming you get the right stuff :)
    • and lastly - learning PHP is no great joy. while it is very easy to pick up the basics and is somewhat simpler than perl in ways, learning PHP's subtle ins and outs is very tedious

    I'd also recommend Preaching Perl gospel to PHP converts... for some good PHP vs. perl comparisons.
    HTH

    _________
    broquaint

      you have all the resources and community support of The Monastery

      She also has all the resources and community support of PHP Freaks, which focuses on PHP and MySQL development.

Re: "cook-ebook" - Should I use Perl or PHP/MySQL?
by Wysardry (Pilgrim) on Feb 05, 2003 at 18:36 UTC

    From your description, I'd say that using PHP would actually make things more complicated than they needed to be.

    Although PHP can be used from the command line, that isn't really what it was designed for. In other words, you'd have to set up a Web server on your machine as well as PHP (and possibly MySQL).

    Perl, on the other hand, is equally at home being called directly, or via a browser.

    1000 recipes shouldn't be a problem using flat text files to hold the data, so you could keep things simple while you're learning, and then transition to a dedicated database system when you were more confident about doing so.

    If installing and setting up Web server software doesn't worry you, I'd recommend using Apache (even on Windows) regardless of whether you choose Perl or PHP.

    You might also want to look at Gossamer Threads' DBMan which is a Perl based database manager that uses flat text files and a browser interface. It is also available in a MySQL version, although that isn't particularly cheap.

    It would give you a head start when designing your own system either way.

    Oh, one last point. The PHP dev team seem to enjoy changing built in functions and/or default settings on a regular basis, thus breaking existing programs when the version is upgraded.

    __________
    "Every program has at least one bug and can be shortened by at least one instruction -- from which, by induction, one can deduce that every program can be reduced to one instruction which doesn't work." -- (Author Unknown)

      Why would she need a Web Server at all?
      Just a lot of hype, is that ;)

      C.

Re: "cook-ebook" - Should I use Perl or PHP/MySQL?
by jacques (Priest) on Feb 05, 2003 at 14:00 UTC
    Are you considering mod_perl? I think it's better to compare PHP to mod_perl than Perl.

    In your situation, I think you should give PHP a twirl if you know less about it than Perl. Consider this project your chance to start learning another popular language. Your resume will thank you.

Re: "cook-ebook" - Should I use Perl or PHP/MySQL?
by mce (Curate) on Feb 05, 2003 at 10:35 UTC
    Well,
    since this site is called perlmonks and not phpmonks, I think you are asking the wrong persons what our suggestion would be.
    Ask the same question on a php group, and I know what their answer will be :-)
    ---------------------------
    Dr. Mark Ceulemans
    Senior Consultant
    IT Masters, Belgium

      I'd like to think a little differently on this. While it is true that many of the users on this site will always say 'perl is the best language no matter what you need to do', I think you'd be surprised at the number of people who will give their honest opinion if they are well-educated in both Perl and the language in question (in this case, php).

      Dare I say it? There are those few times when perhaps Perl is not the best option available for the job. And those who know the true differences between languages, as well as the strengths and weaknesses between them, are not going to lie about which option might be the most suitable.

      Therefore, I think it is perfectly valid for a person to ask if maybe a certain task would be easily accomplished with another language. Remember: just because someone frequently visits perlmonks doesn't mean that they don't know anything else besides perl. I can't find it, but the perlmonks FAQ mentions somewhere that off-topic questions are generally well-accepted here because of the fact that Perl isn't the only thing we here know about :)


            C:\>shutdown -s
            >> Could not shut down computer:
            >> Microsoft is logged in remotely.
          

        You have a valid point about most monks considering different languages equally and if the question was "Should I use Perl or C++" or something of that nature, your point would be validated. However, when you're asking about two languages, one of which is just a subset of another, which do you think people will reccomend?
      Granted there's just a *slight* hint of bias here in the Monastery, but I'm sure I'm not the only person here who believes in the maxim "the best tool for the job". Or would I be the black sheep in that I'd suggest something other than Perl if I believed that for that problem Perl was not the best way to do it?

      --
      Rozallin J. Thompson
      The Webmistress who doesn't hesitate to use stict;

Re: "cook-ebook" - Should I use Perl or PHP/MySQL?
by Aristotle (Chancellor) on Feb 06, 2003 at 12:55 UTC
    Use MySQL or another database to store the recipes - while you could do it with a flatfile, a proper database will let you query against the data with arbitrary criteria at zero coding effort on your side. castaway's DBD::SQLite suggestion is an excellent one. May I suggest you use Class::DBI to write the wrapper around the database; its Perl Advent calendar entry should make it clear how easy it makes database work.

    Makeshifts last the longest.