Kanishka has asked for the wisdom of the Perl Monks concerning the following question:
Venerable sirs!
The result written into the database table by this script below is unreadable. Eg: "Asistente de Dirección" = "Asistente de Dirección"
But if i write the resluts into a text file it is readable. Where have i gone wrong? (Ignore the functions load and Adump)
#!/usr/bin/perl -w use strict; use LWP::UserAgent; use HTTP::Cookies; #use lib '/Perl/site/lib/myModules';s use myModules::initHTTP qw(:all); use DBI; initHttp('http://water:8080'); ###################################################################### +#### my ($dbh) = DBI->connect('DBI:ODBC:xxxx', 'xcx', '') or die "Couldn't +connect to database: " . DBI->errstr; ###################################################################### +#### getAll(); ###################################################################### +#### $dbh->disconnect(); ###################################################################### +#### sub getAll{ print "Fetching All records\n"; my $rs = sendRequest('GET', 'http://www.mycareer.loreal.com/candid +ate/searchjobresults_xml.asp?l=15'); #fetch page while ($rs =~ m!vacancytitle="(.*?)".*?country="(.*?)" startdate=" +(.*?)".*?employmentfield="(.*?)".*?/>!isg){ print $1."\t".$2."\t".$3."\t".$4."\n"; insert($1, $2, $3, $4); } #Adump($rs);exit; } sub insert{ my ($vacancytitle, $country, $startdate, $employmentfield) = @_; my $sth2 = $dbh->prepare('insert into xxxx..Loreal (vacancytitle, +country, startdate, employmentfield) values (?, ?, ?, ?)') or die "Co +uldn't prepare UPDATE statement: " . $dbh->errstr; # this line is onl +y for the Itchy server $sth2->execute ($vacancytitle, $country, $startdate, $employmentfi +eld) or die "Couldn't execute INSERT statement: " . $sth2->errstr; $sth2->finish; } sub load { $/ = undef; open OUT, 'optList.asp'; my $p = <OUT>; close OUT; return $p; } sub Adump { my $lst = shift; open OUT, '>Loreal.xml'; print OUT $lst; close OUT; }
Formatting added by GrandFather
2006-10-16 Retitled by GrandFather, as per Monastery guidelines
Original title: 'The result is unreadable'
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Fine when written to text file, but unreadable when written to database table
by shmem (Chancellor) on Oct 16, 2006 at 06:33 UTC | |
|
Re: Fine when written to text file, but unreadable when written to database table
by graff (Chancellor) on Oct 16, 2006 at 07:12 UTC | |
by Kanishka (Beadle) on Oct 16, 2006 at 07:59 UTC | |
by graff (Chancellor) on Oct 16, 2006 at 08:18 UTC | |
|
Re: Fine when written to text file, but unreadable when written to database table
by tilly (Archbishop) on Oct 16, 2006 at 04:58 UTC | |
by Kanishka (Beadle) on Oct 16, 2006 at 06:03 UTC |