# PerlAppResource Constructors

- Package: [CommunityToolkit.Aspire.Hosting.Perl](/reference/api/csharp/communitytoolkit.aspire.hosting.perl.md)
- Type: [PerlAppResource](/reference/api/csharp/communitytoolkit.aspire.hosting.perl/perlappresource.md)
- Kind: `Constructors`
- Members: `1`

Represents a Perl application resource.

## PerlAppResource(string, string, string)

- Name: `Constructor(string, string, string)`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/d9dc6fc02412d7398c5722840513d99965a6e98f/src/CommunityToolkit.Aspire.Hosting.Perl/PerlAppResource.cs#L61)

Represents a Perl application resource.

```csharp
public class PerlAppResource
{
    public PerlAppResource(
        string name,
        string executablePath,
        string appDirectory)
    {
        // ...
    }
}
```

## Parameters

- `name` (`string`)
  The name of the resource in the application model.
- `executablePath` (`string`)
  The path to the Perl executable. This can be:

  - An absolute path: "/usr/bin/perl"
  - A relative path: "./local/bin/perl"
  - A command on the PATH: "perl" or "myperl"

  The executable is typically `"perl"` (resolved from PATH), or a path to a perlbrew-managed Perl installation's bin directory.
- `appDirectory` (`string`)
  The working directory for the Perl application. Perl scripts and modules will be resolved relative to this directory. This is typically the root directory of your Perl project containing your main script and any local modules.

## Remarks

This resource allows Perl applications (scripts, web servers, APIs, background services) to run as part of a distributed application. The resource manages the Perl executable, working directory, and lifecycle of the Perl application.

Perl applications can expose HTTP endpoints, communicate with other services, and participate in service discovery like other Aspire resources. They support automatic OpenTelemetry instrumentation for observability when configured with the appropriate Perl packages.

This resource supports various Perl execution environments including:

- System Perl installations
- User specified Perl environments
- Local::Lib environments

## Examples

Add a Perl web application using Mojolicious or Dancer2:

```csharp
var builder = DistributedApplication.CreateBuilder(args);

var perl = builder.AddPerlApi("api", "../perl-api", "app.pl")
    .WithHttpEndpoint(port: 5000)
    .WithArgs("--host", "0.0.0.0");

builder.AddProject<Projects.Frontend>("frontend")
    .WithReference(perl);

builder.Build().Run();
```
