Amped::On::IO::All
Here's a code snippet that uses CPAN module IO::All to return a pdf of a dynamic HTML page to the browser. IO::All demonstrates the potential for API simplication w/operator overloading when applied to something mundane like file access:
my $fname = ('?'); # create temp file handle
my $htmldoc = io("| $htmldoc -t pdf14 -f $fname --datadir $htmldoc_dir --footer t/D -")
or $logger->fatal( "Couldn't open htmldoc: $! $?" );
$html > $htmldoc; # pass string to pipe
$htmldoc->close();
my $pdf = io($fname);
my $binary = $pdf->binary->scalar; # slurp up output pdf file
$pdf->unlink(); #delete temp file
$pdf->close();
return $binary;
IO::All author Ingy has done some really good work smoothing over the rough corners of perl. If that's something that interests you, I suggest looking over two of his other modules: Spiffy and YAML. The ajax-enthusiasts are discovering the YAML-subset JSON ... so maybe it will get some of the popularity it deserves.
9:24:51 AM
|