Women in Technology

Hear us Roar



Article:
  Apache Web-Serving With Mac OS X, Part 5
Subject:   Do it over again with Perl
Date:   2002-03-12 12:56:52
From:   dicklacara
I was so encouraged by the results of your excellent tutorial on pHp/mySQL... I took a shot at "installing" mySQL for Perl... no success.


I have done some web programming in Perl, but never was involved with the install side of things,


A short tutorial on adding mySQL to the OS X Perl package woukd be appreciated.


Maybe, someday we'll have ColdFusion on OS X!


Dick

Full Threads Oldest First

Showing messages 1 through 3 of 3.

  • Morbus Iff photo Do it over again with Perl
    2002-03-13 20:51:56  Morbus Iff | O'Reilly Author [View]

    Ultimately, you'll want to either look at or join the osx@perl.org list. You can see the archives here (there are some mentions of DBI).

    I've gone through a lot of Perl installations on my perl box, so, in my case, I just had to:

    sudo perl -MCPAN -eshell
    install Bundle::DBD::mysql

    Sat through a few errors, and when things were all finished, this script worked correctly (it assumes the database has been created as per the PHP script, and that some data has been entered).

    #!/usr/bin/perl
    use DBI;

    $dsn = "DBI:mysql:database=test;host=127.0.0.1;";
    $dbh = DBI->connect($dsn, "root", "");
    $sth = $dbh->prepare("SELECT * FROM wisdom");
    $sth->execute;
    while (my $ref = $sth->fetchrow_hashref()) {
    print "$ref->{'id'}: $ref->{'author'} sez: $ref->{'wisdom'}\n";
    }
    $sth->finish;
    • Do it over again with Perl
      2002-03-18 19:45:57  gskluzacek [View]

      what does the 2 lines below do?

      sudo perl -MCPAN -eshell
      install Bundle::DBD::mysql

      The 2nd one looks to install the mysql database driver for dbi, but the 1st one I'm clueless on. Is there something similar to instal the acutal DBI module? Thanks.

      Greg Skluzacek
      gskluzacek@mac.com
      • Morbus Iff photo Do it over again with Perl
        2002-03-19 14:04:21  Morbus Iff | O'Reilly Author [View]

        "sudo" says to run the next command as the root user. "perl" starts the perl interpreter, and automatically loads in a module called "CPAN" ("-MCPAN" is equivalent to "use CPAN;"). Finally, "-e" is the "execute this perl code" command, and we're saying to execute the "shell" command of CPAN.

        The second command installs the actual module. If you know your module name, you can use it - so "install XML::Parser", "install LWP::Simple", "install DBI::mysql", and so on and so forth. If you do the "Bundle::DBD::mysql" as above, then you don't have to worry about installing the matching DBI module - it's contained within this "Bundle".