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: Intermediate: Re: [limner] error messages: Edit Log



limner
Novice

Mar 13, 2014, 7:33 AM


Views: 4131
Re: [limner] error messages

This is the script:

Code
#!C:\strawberry\perl\bin\perl 
use WWW::Mechanize::Firefox;
use Text::Unaccent;
use Win32::Process::List;
use Win32::Process;
use Win32;
use Win32::Process::Kill;
use DBI;
use CGI;



require "C:\\app\\Limner\\procedure\\esamina_bookings\\conndb\\coord_database.pl";
coord::head4();




require "C:\\app\\Limner\\procedure\\esamina_bookings\\conndb\\tns_sbeauty.pl";
tns::head3();
$dbh=$tns::dbh1;








$gruppo=$ARGV[0]; ### Gruppo da elaborare (G01 - G02 ecc ecc)
$yyyymm=$ARGV[1]; ### Periodo da elaborare tipo yyyy-mm (Es 2014-06)

$hotels=$dbh->prepare(" SELECT id_sito_booking ,id_hotel ,nome
FROM lista_hotel
where upper(attivo) = 'Y'
and gruppo = '$gruppo'
order by id_hotel asc ");
$hotels->execute();








while (@rowhotel = $hotels->fetchrow_array)
{

# $resetta="n";


$data1=$dbh->prepare(" select to_char(sysdate,'yyyy-mm')
,to_char(sysdate+1,'dd')
from dual ");
$data1->execute();
@rg1 = $data1->fetchrow_array;

$test=$rg1[0];
$na=$rg1[1];



$data2=$dbh->prepare(" select case when $test = $yyyymm then to_number($na)
else 1
end
from dual ");
$data2->execute();
@rg2 = $data2->fetchrow_array;

$ng=$rg2[0];


$data3=$dbh->prepare(" select to_number(to_char(last_day(to_date('01-$yyyymm','dd-yyyy-mm')),'dd'))
from dual ");

$data3->execute();
@rg3 = $data3->fetchrow_array;

$nmax=$rg3[0];




while( $ng <= $nmax )
{

my $mech = WWW::Mechanize::Firefox->new( launch => 'C:\Program Files (x86)\Mozilla Firefox\firefox.exe'
,tab => 'current' );

$dt_in=$dbh->prepare(" select to_char(to_date('$yyyymm-$ng','yyyy-mm-dd'),'yyyy-mm-dd')
from dual ");
$dt_in->execute();
$chin= $dt_in->fetchrow_array;


$dt_out=$dbh->prepare(" select to_char(to_date('$yyyymm-$ng','yyyy-mm-dd')+1,'yyyy-mm-dd')
from dual ");
$dt_out->execute();
$chout= $dt_out->fetchrow_array;


$id_sito=$rowhotel[0];
$ch_in=$chin;
$ch_out=$chout;
$id_h=$rowhotel[1];
$res=$resetta;

print STDERR "sito=$id_sito ch-in=$ch_in ch-out=$ch_out id_hotel=$id_h periodo=$yyyymm ng=$ng nmax=$nmax \n";






$nomefile=$dbh->prepare(" select 'bkg_'||'$ch_in'||'_'||'$id_h'||'.temp'
,'bkg_'||'$ch_in'||'_'||'$id_h'||'.html'
from dual ");
$nomefile->execute();
@nfile= $nomefile->fetchrow_array;


$tfile=$nfile[0]; p
$hfile=$nfile[1];

$dirro="C:\\app\\Limner\\procedure\\esamina_bookings\\htmlfiles\\tab_html_files\\";


$dest=join("",$dirro,$tfile);

$url_base="http://www.booking.com/hotel/it/";

#$url="$url_base$id_sito?checkin=$ch_in&checkout=$ch_out";

@in=split('-' ,$ch_in);
@out=split('-' ,$ch_out);

$dd_ch_in=@in[2];
$yyyymm_ch_in=join('-' ,@in[0] ,@in[1]);

$dd_ch_out=@out[2];
$yyyymm_ch_out=join('-' ,@out[0] ,@out[1]);

$url="$url_base$id_sito?checkin_monthday=$dd_ch_in&checkin_year_month=$yyyymm_ch_in&checkout_monthday=$dd_ch_out&checkout_year_month=$yyyymm_ch_out";

$mech->save_url( $url ,$dest );






$FILE_TEMP="C:\\app\\Limner\\procedure\\esamina_bookings\\htmlfiles\\tab_html_files\\$tfile";
$FILE_DEF ="C:\\app\\Limner\\procedure\\esamina_bookings\\htmlfiles\\tab_html_files\\$hfile";

open my $INFILE ,'<' ,$FILE_TEMP;
open my $OUTFILE ,'>' ,$FILE_DEF;

$n=0;

while (my $line = <$INFILE>) {
$linea_def=unac_string("UTF-8",$line);
$lung=length($linea_def);
if ($lung > 3950)
{ @linee_multiple = split(' ',$linea_def);
foreach my $valur (@linee_multiple)
{ ++$n;
print $OUTFILE $n." 1701Limner1701 ".$valur."\n"; }
}
else
{ ++$n;
print $OUTFILE $n." 1701Limner1701 ".$linea_def; }
}

close $INFILE;
close $OUTFILE;









$ng=$ng+1;

}
}



(This post was edited by FishMonger on Mar 13, 2014, 7:45 AM)


Edit Log:
Post edited by FishMonger (Veteran) on Mar 13, 2014, 7:45 AM


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

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