# WithPerlbrewEnvironment

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

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
func (PerlAppResource) 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()`.

## Applies to

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