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

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

From:
Ken Cotterill
Date:
April 13, 2017 12:45
Subject:
[perl #131142] "if" pragma POD addition for modules with an emptyimport list
Message ID:
rt-4.0.24-14352-1492053718-1491.131142-75-0@perl.org
# New Ticket Created by  Ken Cotterill 
# Please include the string:  [perl #131142]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=131142 >


This relates to if.pm (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.

--- if.pm	2017-04-12 08:26:15.000000000 +1000
+++ if-new.pm	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>:




nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About