It's possible that my code isn't doing what I think that it is, but I don't think I am opening the input file twice.

When you do this:

my $group = get_page_cnt($append_pdf);
a file handle is created, the data file is opened for reading, some amount of it (I don't know how much) is read into memory and processed in some way, the file handle is closed, and the result of processing is returned as a scalar value.

Then, when you do this:

my $otherpdf = CAM::PDF->new($dir."data2\\".$append_pdf); $pdf->appendPDF($otherpdf);
another file handle is created, that same input file is opened and read, and this time its contents are copied to an output file. In this latter case, it's very likely that the OS and/or system hardware have cached the file and its contents, so the second open/read/close will almost certainly be faster than the first one, but there are still two instances of opening the file and linking it to a file handle for access.

Meanwhile, there's the separate issue of how many times a given output file needs to be closed and then reopened, depending on how the particular ordering of input file names (as returned by "readdir") relates to the page counts of the files.


In reply to Re^5: Am I on the right track? by graff
in thread Am I on the right track? by Pharazon

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.