I have some code I'm working with which had the assignment of a base PDF file in a giant 'if elsif' block. It was assigning a different base PDF for form filling using CAM::PDF based on what kind of form it was, and what state we were using. Let's say they were contracts, of two types, and there were two states, so the block went something like this:
if ($type eq 'A'){
if ($state eq 'GA'){
$form{source} = 'files/blanks/state/GA/A/contract.pdf';
}elsif($state eq 'TX'){
$form{source} = 'files/blanks/state/TX/A/contract.pdf';
}
elsif ($type eq 'B'){
if ($state eq 'GA'){
$form{source} = 'files/blanks/state/GA/B/contract.pdf';
}elsif($state eq 'TX'){
$form{source} = 'files/blanks/state/TX/B/contract.pdf';
}
}
This worked flawlessly, but it could be more elegant. I wanted this:
$form{source} = "files/blanks/state/$state/$type/contract.pdf";
I'm printing out the $form{source} value in a log, but if I reassign the value with the latter statement, though it looks identical to me in the log, the file doesn't open correctly. I have traced this through to line 384 in CAM::PDF (PDF.pm) where it tests for $self->_startdoc(). Even though the content loaded is identical, $self->_startdoc() returns undef if I assign the source via the simple assignment method and 1 if it was via the if/else method.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.