---
name: "Devel::BeginLift"
section: "3pm"
platform: "linux"
package: "libdevel-beginlift-perl"
version: "0.001003-1+b2"
release: "Debian 8 (Jessie)"
platforms: ["linux"]
url: "https://new.carta.tech/Devel::BeginLift"
---

# Devel::BeginLift(3pm)

make selected sub calls evaluate at compile time

## NAME

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

## SYNOPSIS

```
  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

## DESCRIPTION

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.

### import

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

Calls Devel::BeginLift-\>setup\_for(\_\_PACKAGE\_\_ =\> \\@list\_of\_subs);

### unimport

```
  no Devel::BeginLift;
```

Calls Devel::BeginLift-\>teardown\_for(\_\_PACKAGE\_\_);

### setup\_for

```
  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.

### teardown\_for

```
  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.

### setup\_for\_cv

```
  $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"`.

### teardown\_for\_cv

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

Deregisters begin lifting magic referred to by `$id`.

## AUTHOR

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

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

## LICENSE

This library is free software under the same terms as perl itself
