ssimms / pdfapi2

Create, modify, and examine PDF files in Perl
Other
15 stars 20 forks source link

Use strict pragma wherever possible #16

Closed paultcochrane closed 7 years ago

paultcochrane commented 7 years ago

... where every module in the distribution now uses the strict pragma. Only in PDF::API2 was it necessary to turn off strict for 'vars'. The reason being the options passed around are sometimes handles as arrays and other times as hashes and it would require lots of digging to sort that particular issue out. Nevertheless, it was possible to add strict to all modules where this was missing and to make any variables lexical which weren't already so. In many cases the new_api method needed to have the $self variable made lexical and this happened so often, and with the same structure that it looked like this was a copy-paste issue. Nevertheless, this variable is now lexical inside new_api throughout the code. The tests all pass and the Test::Kwalitee::Extra tests no longer complain that use strict isn't used throughout the distribution. This change should thus fix the use_strict CPANTS violation and allows the distribution to use current Perl best practice.

This PR is submitted in the hope that it is helpful. If it can be improved in any way, please just let me know and I'll update it appropriately and resubmit.

ssimms commented 7 years ago

I don't see an obvious way to add my local changes to this pull request (I'm relatively new to collaboration with GitHub). If that's possible, let me know how; otherwise, I'll add them in after I hear from you about PNM.pm.

ssimms commented 7 years ago

I looked through the issues with strict vars in PDF/API2.pm and was able to eliminate them, so I've merged this pull request manually, including the changes mentioned above, and removing strict subs from PNM.pm.

Thanks for the push to get this done. :-)

paultcochrane commented 7 years ago

No worries! Only too pleased to help! The reason why the no strict 'subs' was in that patch was because there were still bareword filehandles floating around, and the only way to get things to compile with use strict is to turn strict off on subs. Of course, since the other patch removing the bareword filehandles was merged before this patch, consequently the no strict 'subs' was no longer necessary.

Am really stoked that you're merging these changes :-) They're mostly trivial/cosmetic changes, however I hope they're useful!