# PerlAppResource.WithPerlbrewEnvironment

- Module: [CommunityToolkit.Aspire.Hosting.Perl](/reference/api/go/communitytoolkit.aspire.hosting.perl.md)
- Defined on: [PerlAppResource](/reference/api/go/communitytoolkit.aspire.hosting.perl/perlappresource.md)
- Version: `13.6.1`
- Kind: `method`

Configures the Perl application to use a specific perlbrew-managed Perl version. This resolves the Perl executable from the perlbrew installation and updates the resource's command and environment variables so that all subsequent operations use the specified Perl version.

## Remarks

Perlbrew is Linux-only. On Windows, an `InvalidOperationException` is thrown
with a recommendation to use Berrybrew.
When combined with `WithLocalLib`, modules are installed into the
local directory rather than the perlbrew tree, keeping the perlbrew installation clean
and enabling per-project module isolation.

## Definition

```go
type PerlAppResource interface {
    // ... omitted for brevity
    WithPerlbrewEnvironment(
        version string,
        options ...*WithPerlbrewEnvironmentOptions,
    ) PerlAppResource
}
```

## Signature

```go
WithPerlbrewEnvironment(
    version string,
    options ...*WithPerlbrewEnvironmentOptions,
) PerlAppResource
```

## Parameters

- `version` (`string`) -- The perlbrew version name. Accepts both `"5.38.0"` and `"perl-5.38.0"`.
- `options` (`...*WithPerlbrewEnvironmentOptions`) -- optional settings, see [Options](#options)

## Options

Optional parameters are passed in a trailing `options ...*WithPerlbrewEnvironmentOptions` argument.

- `PerlbrewRoot` (`*string`) -- Optional explicit path to the perlbrew root directory. If `null`, resolves from the `PERLBREW_ROOT` environment variable, or defaults to `~/perl5/perlbrew`.

## Returns

[`PerlAppResource`](/reference/api/go/communitytoolkit.aspire.hosting.perl/perlappresource.md) -- A reference to the `IResourceBuilder`.

Returns a handle; failures surface later via `Err()`.

## Defined on

- [PerlAppResource](/reference/api/go/communitytoolkit.aspire.hosting.perl/perlappresource.md) -- `handle`
