[PERL]Perl Resource Center

[PERL]Perl Resource Center

Postby mihu » Fri Feb 08, 2008 4:15 pm

How to install Perl library?
Go to cpan -> "install Bundle::DBD::mysql"

MySQL
O'Reilly - MySQL & mSQL
http://www.oreilly.com/catalog/msql/chapter/ch10.html

Using Perl DBI to interface to MySQL
http://www.danchan.com/feature/2000/10/ ... mysql3.htm
Code: Select all
use DBI;

my $dsn = 'DBI:mysql:my_database:localhost';
...
my $dbh = DBI->connect($dsn, $db_user_name, $db_password);

my $sth = $dbh->prepare(qq{
    # ... SQL STATEMENT ...
});
$sth->execute();

while ( my( $xxx) = $sth->fetchrow_array() ) {
    # .... you can use $xxx any where
}


XML
O'Reilly XML.com - Perl XML Quickstart: The Perl XML Interfaces
http://www.xml.com/pub/a/2001/04/18/perlxmlqstart1.html
- the sample code is available for download (different approach to generate xml from perl) and I learn how to use perl generate xml from those sample files.
Code: Select all
use XML::DOM;
...
# my auto-generate node function to demo how to use perl w/ XML::DOM
sub generateNode {
    my($doc, $top_node, $tag_name, $tag_text) = @_;
    if ( $tag_text eq ""  ) {
    } else {
        my $tag = $doc->createElement($tag_name);
        $tag->appendChild($doc->createTextNode($tag_text));
        $top_node->appendChild($tag);
    }
}


Perl-XML Frequently Asked Questions
http://perl-xml.sourceforge.net/faq/
User avatar
mihu
 
Posts: 183
Joined: Thu Jan 10, 2008 10:44 am

Return to Perl

Who is online

Users browsing this forum: No registered users and 1 guest

cron