writch has asked for the wisdom of the Perl Monks concerning the following question:
This worked flawlessly, but it could be more elegant. I wanted 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'; } }
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.$form{source} = "files/blanks/state/$state/$type/contract.pdf";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: String assignment oddity
by syphilis (Archbishop) on Mar 01, 2018 at 22:28 UTC | |
|
Re: String assignment oddity
by Eily (Monsignor) on Mar 02, 2018 at 14:44 UTC | |
|
Re: String assignment oddity
by writch (Sexton) on Apr 17, 2018 at 15:19 UTC |