GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Devel::BeginLift(3) User Contributed Perl Documentation Devel::BeginLift(3)

Devel::BeginLift - make selected sub calls evaluate at compile time

  use Devel::BeginLift qw(foo baz);
  
  use vars qw($i);
  
  BEGIN { $i = 0 }
  
  sub foo { "foo: $_[0]\n"; }
  
  sub bar { "bar: $_[0]\n"; }
  
  for (1 .. 3) {
    print foo($i++);
    print bar($i++);
  }
  
  no Devel::BeginLift;
  
  print foo($i++);

outputs -

foo: 0 bar: 1 foo: 0 bar: 2 foo: 0 bar: 3 foo: 4

Devel::BeginLift 'lifts' arbitrary sub calls to running at compile time - sort of a souped up version of "use constant". It does this via some slightly insane perlguts magic.

  use Devel::BeginLift qw(list of subs);

Calls Devel::BeginLift->setup_for(__PACKAGE__ => \@list_of_subs);

  no Devel::BeginLift;

Calls Devel::BeginLift->teardown_for(__PACKAGE__);

  Devel::BeginLift->setup_for($package => \@subnames);

Installs begin lifting magic (unless already installed) and registers "${package}::$name" for each member of @subnames to be executed when parsed and replaced with its output rather than left for runtime.

  Devel::BeginLift->teardown_for($package);

Deregisters all subs currently registered for $package and uninstalls begin lifting magic is number of teardown_for calls matches number of setup_for calls.

  $id = Devel::BeginLift->setup_for_cv(\&code);

Same as "setup_for", but only registers begin lifting magic for one code reference. Returns an id to be used in "teardown_for_cv".

  Devel::BeginLift->teardown_for_cv($id);

Deregisters begin lifting magic referred to by $id.

Matt S Trout - <mst@shadowcatsystems.co.uk>

Company: http://www.shadowcatsystems.co.uk/ Blog: http://chainsawblues.vox.com/

This library is free software under the same terms as perl itself
2010-05-11 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.