Hi moders, Apache/1.3.26 (Unix) mod_perl/1.27
I want to hold my hands up straight away and confess to being a bit green with perl generally. The script I have below is as sparse as I can make it. What I have found it that if I remove all the PDF stuff it works fine. With the PDF stuff in appears to run twice. By twice I mean that the output to STDERR when I am looping through the request starts again. It needs a uri like: http://www.server.com/junk?users=Dermot+Paikkos&auth=manager&dir=10-7- 04&submit=Go It modifies the date to match an existing dir and finds the user's file. Opens that file and output's to a pdf. I should state the final PDF is fine, give it one user and you get one page, give it four and you get four. The problem for me is that as it loops through each users file twice I am having trouble parsing the data in the way I'd like. I could focus on simply parsing the data as it comes but I thought there might be an explanation for the behaviour. This is what you see in the error.log: [Thu Jul 29 12:58:31 2004] [notice] Apache/1.3.26 (Unix) mod_perl/1.27 configured -- resuming normal operations [Thu Jul 29 12:58:31 2004] [notice] Accept mutex: sysvsem (Default: sysvsem) Dermot Paikkos size of users is 1 Dermot Paikkos size of users is 1 This is the perl script. Any ideas? Am I being extra dim this week? Thanx. Dp. ============ JUNK.PM ============ package SPL::junk; use Apache::Constants qw(:common REDIRECT); use Apache::Request; use Apache::File; use PDF::Create; use strict; use warnings; use diagnostics; use Carp; $| =1; sub handler{ my $r = Apache::Request->new(shift); my @users; my $dir_date; my $clock = "/mnt/home/clock/logs/"; foreach my $param ($r->param) { if ($param =~ /\busers\b/) { push(@users,$r->param($param)); print STDERR scalar($r->param($param))."\n"; } elsif ($param =~ /dir/) { $dir_date = $r->param($param); } } my $size_of = @users; print STDERR "size of users is $size_of\n"; my $dir = &mod_dir($dir_date); my $log_path = "$clock"."$dir"; my ($tmpfile,$tmpfh) = Apache::File->tmpfile; my $pdf = new PDF::Create('filename' => "$tmpfile", 'Author' => 'Dermot Paikkos', 'Title' => 'User Reports', 'PageMode' => 'UseThumbs', ); foreach my $f (@users) { my $file_path = "$log_path"."/"."$f".".clk"; my $fh = Apache::File->new($file_path) || die "Can't open $file_path: $!\n"; my $page = $pdf->new_page; my $x = 720; while (<$fh>) { $page->string($pdf->font,12,22,$x,"$_"); $x -= 20; } } $pdf->close; $r->set_content_length(-s $tmpfile); $r->send_http_header('application/pdf'); seek $tmpfh, 0,0; $r->send_fd($tmpfh); ######## SUBS ####### sub mod_dir { my $date = shift; (my $end) = substr($date,-2); my $new_end = "1"."$end"; substr($date,-2,2,"$new_end"); return $date; } return OK; } # End of handler 1; =========================== ~~ Dermot Paikkos * [EMAIL PROTECTED] Network Administrator @ Science Photo Library Phone: 0207 432 1100 * Fax: 0207 286 8668 -- Report problems: http://perl.apache.org/bugs/ Mail list info: http://perl.apache.org/maillist/modperl.html List etiquette: http://perl.apache.org/maillist/email-etiquette.html