CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
store in DB with perl::dbi : plz review the code

 



dilbert
User

Oct 22, 2010, 9:11 AM

Post #1 of 3 (407 views)
store in DB with perl::dbi : plz review the code Can't Post

 
i am new to the list - and my name is floo

i am new to Perl and new to MySQL too.

Well i want to use store a result of a parser job in a mysql-db: and i also want to use a MySQL-DB. Perhaps i should take Perl::DBI.

see the following code - and the output



!/usr/bin/perl

use strict; use warnings;
use HTML::TableExtract;
use YAML;

my $te = HTML::TableExtract->new( attribs => {
border => 0,
bgcolor => '#EFEFEF',
leftmargin => 15,
topmargin => 5,
});

$te->parse_file('kultus-bw.html');
my ($table) = $te->tables;

for my $row ( $table->rows ) {
cleanup(@$row);
print "@$row\n";
}

sub cleanup {
for ( @_ ) {
s/\s+//;
s/[\xa0 ]+\z//;
s/\s+/ /g;
}
}

Output


School: MyShool
Schultype: lycee
adresss: champs-elysee, 75000 Paris
Postbox: Keine Angabe
Telefon: 45 - 07361/680040
Fax: 07361/680040
E-Mail: lycee@schools.fr
Internet: www.lycee-paris.fr
departement: Paris Rubaix
head of school: Bill Clinton
deputy: Ron Wood
number of pupils: 259
classes: 8
number of teachers: 22
region: paris-midi
gouvernment: the french center council


Hard to be too specific as my question is very general. I've retrieved pages using LWP and used TableExtract to extract data and now i want to store the output in a mysql-database. I haven't used Mech, but by all accounts it is simpler than LWP.

Well i want to use LWP - and i also want to use a MySQL-DB. Perhaps i should take Perl::DBI.

Well do not bear with me. I am a beginner when it cones to perl.
You see: The data is parsed; I now want to store this results in a database:

How do i do that.

Note - i have many pages of the above mentioned. So it is worth to do the storage with MySQL

Can you give me some hints how to do it with Perl and DBI

love to hear from you

Regards dilbert


winfinit
User

Oct 22, 2010, 5:15 PM

Post #2 of 3 (404 views)
Re: [dilbert] store in DB with perl::dbi : plz review the code [In reply to] Can't Post

Dilbert,

i would recommend just to read some tutorials that are already there, for example this:

http://www.perl.com/pub/1999/10/DBI.html

hope this would get you started
-winfinit


dilbert
User

Oct 22, 2010, 9:37 PM

Post #3 of 3 (401 views)
Re: [winfinit] store in DB with perl::dbi : plz review the code [In reply to] Can't Post

hi there - many thanks for the hint!

i do that!

come back and report all my findings

greetings

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives