Is this your normal indentation? Looks horrible. Check out perltidy, a script than can repair this.

I would also suggest using

use strict; use warnings;

I see you have practically just one really big loop where you process each record. It would have been easy to do some really basic profiling by just putting  print "Doing xyz now\n" every few lines and observing whether that minute for each record is wasted in one place or distributed evenly.

Please read How do I post a question effectively?. You could have done the profiling before posting the code and then would have known which part of the code is important to post. You could have provided sample data (a few records) so that other monks could run your code.

I don't have any experience with PDF::API2, but I'm guessing that a lot of the stuff you have in your loop could be moved before the loop. Definitely all the constant strings you create, all the font assignments, probably also the assignments of $pdb, $jpeg, $png, $tag. Just try it and see if it works.

The same could be done with the images of the chars. Your code probably can be changed to:

my %char_pics=(); # before the big loop while(<DATAFILE>){ ... foreach(@chars) { if(!$_ == "") { if (exists $char_pics{$_}) { $img= $char_pics{$_}; } else { $img=$pdf->image_png("/var/www/html/font_test/Pumpkins +/$_.png"); $char_pics{$_}= $img; } vr->image(... ...

If this works it could be quite a speedup since each char has to be read only once from disk instead of every time it is printed


In reply to Re^2: PDF::API2 processing time by jethro
in thread PDF::API2 processing time by ndnalibi

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.