Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<h2>Exporting</h2> <p>Manually calling @EXPORT =() stuff is getting a bit haggard. </p> <pre><code>package Bar; use strict; use warnings; use Sub::Exporter -setup =&gt; { exports =&gt; [qw[ foo ]], groups =&gt; { default =&gt; [qw[ foo ]], } }; sub foo(){ }; 1; </code></pre> <p>Use:</p> <pre><code>use strict; use warnings; use Bar foo =&gt; { -as-&gt; 'Foo' }; </code></pre> <p>Sub::Exporter can do lots of awesome stuff, like group exports, group exclusion, builder methods ( Ie: how the subs it exports work are determined by passed parameters , and the subs are generated inside other subs, etc ) </p> <ul> <li><a href="http://p3rl.org/Sub::Exporter::Tutorial" rel="nofollow noreferrer">Sub::Exporter tutorial</a></li> <li><a href="http://p3rl.org/Sub::Exporter" rel="nofollow noreferrer">Sub::Exporter</a></li> </ul> <h2>Renaming</h2> <p>For renaming things it might be better to have a secondary function which just stands as a legacy function that Carp()s when its called to recommend the code that points to it everywhere to be moved to the new method. This will increase consistency codewide. </p> <p>Then when your tests stop spouting forth warnings, you can remove the legacy function. </p> <pre><code>sub old { # line 1 Carp::carp('Legacy function \'old\' called, please move to \'newmethod\' '); goto &amp;newmethod; # this passes @_ literally and hides itself from the stack trace. } # line 4 sub newmethod { # line 6 Carp::cluck('In New Method'); return 5; } # line 9 print old(), "\n"; # line 11 </code></pre> <pre> Legacy function 'old' called, please move to 'newmethod' at code.pl line 2 main::old() called at code.pl line 11 In New Method at code.pl line 7 main::newmethod() called at code.pl line 11 5 </pre> <p>Note how the warnings in newmethod look exactly like they'd been called directly. </p> <h1> </h1>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload