Estoy tratando de guardar la salida en un archivo PDF, ya que gracias a ustedes pude hacerlo en formato HTML.
Tengo un problema: solamente me guarda el último resultado:
Using perl Syntax Highlighting
#!/usr/bin/perl
use warnings
;
use strict
;
use HTTP
::Request;
use LWP
::UserAgent;
my $host = 'http://localhost';
my $string = "marcos";
#Lista de paginas en un array, así es fácil agregar más páginas
my @paginas = ("legajo.php","legajos.php");
#Abrimos el archivo con la lista de archivos a leer
open my $FILE, '<', 'lista_de_archivos.txt' or die $!;
my @archivos = <$FILE>;
close $FILE;
#Creamos nuestro objeto LWP
my $ua = LWP
::UserAgent->new();
$ua->timeout(30
);
#Iteramos en cada archivo
for my $archivo(@archivos){
chomp $archivo;
#Iteramos en cada pagina
for my $pagina(@paginas){
#Armamos el url
my $url = join "/", $host, $pagina, $archivo;
#Creamos un nuevo request
my $req = HTTP
::Request->new(GET
=>$url);
my $response = $ua->request($req);
if ($response->is_success) {
if( $response->content =~ /$string/ ) {
#Cerramos el reporte
my $pdf = new PDF
::Report(
PageSize
=> 'A4',
PageOrientation
=> 'Portrait'
);
$pdf->newpage(1
);
$pdf->setFont('Helvetica-bold');
$pdf->setSize(14
);
my ($width, $height) = $pdf->getPageDimensions();
$pdf->centerString(0
, $width, $height-40, "Reporte");
$pdf->setFont('Helvetica');
$pdf->setSize(10
);
$text2="Host: $host";
$text3="Archivo: lista_de_archivos.txt";
$text4="String: $string";
$text5="Reporte: reporte.pdf";
$text6="$url\n";
$pdf->addParagraph($text1, 30
, $height-70
, $width-60
, 30
, 25
, 10
);
$pdf->addParagraph($text2, 30
, $height-80
, $width-60
);
$pdf->addParagraph($text3, 30
, $height-90
, $width-60
);
$pdf->addParagraph($text4, 30
, $height-100
, $width-60
);
$pdf->addParagraph($text5, 30
, $height-110
, $width-60
);
$pdf->addParagraph($text6, 30
, $height-120
, $width-70
);
open(PDF
, "> reporte.pdf") or die "ERROR: No puedo escribir en reporte.pdf: $!\n";
print PDF
$pdf->Finish();
}
}
}
}
close(PDF
);
exit;Coloreado en 0.004 segundos, usando
GeSHi 1.0.8.4
Si alguno me puede ayudar se lo voy agradecer
![Very Happy :D](https://perlenespanol.com/foro/images/smilies/icon_biggrin.gif)