develooper Front page | perl.perl5.porters | Postings from April 2017

[perl #131142] "if" pragma POD addition for modules with an emptyimport list

Ken Cotterill
April 13, 2017 12:45
[perl #131142] "if" pragma POD addition for modules with an emptyimport list
Message ID:
# New Ticket Created by  Ken Cotterill 
# Please include the string:  [perl #131142]
# in the subject line of all future correspondence about this issue. 
# <URL: >

This relates to (version: 0.0606).

The current documentation refers to loading modules
with or without ARGUMENTS (i.e. for import()).

It doesn't mention using an empty import list
which is not possible with the current implementation.

This patch adds a few lines to the POD to
explain this; it also suggests a workaround.

---	2017-04-12 08:26:15.000000000 +1000
+++	2017-04-12 09:31:05.000000000 +1000
@@ -50,6 +50,15 @@
  If you don't use the fat comma (eg you don't have any ARGUMENTS),
  then you'll need to quote the MODULE.
+If you wanted ARGUMENTS to be an empty list, i.e. have the effect of:
+    use MODULE ();
+you can't do this with the C<if> pragma; however, you can achieve
+exactly this effect, at compile time, with:
+    BEGIN { require MODULE if CONDITION }
  =head2 EXAMPLES
  The following line is taken from the testsuite for L<File::Map>: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About