# LibTmux::Server::get_environment

- **Module:** LibTmux
- **Package:** LibTmux
- **Language:** Perl
- **Kind:** method
- **Source:** https://github.com/libtmux/libtmux-perl/blob/352715a4fa66a96eed7763b90daaa536aa2f121d/packages/core/lib/LibTmux/Server.pm#L1104
- **Page:** https://libtmux.org/en/perl/latest/reference/libtmux-server-get_environment/

```
sub get_environment($self, %args)
```

`get_environment(name => env_name, session => session_target?)`.

Read a session/global variable and return its octets. The native quoted representation is parsed as data; no shell evaluates it. Literal backslashes, newlines and non-UTF-8 bytes remain distinct. Empty text and '0' remain values. Performs I/O without mutation; missing or explicitly unset variables throw [`"Command" in LibTmux::X`](/en/perl/latest/reference/libtmux-x-command/), and malformed output throws [`"Codec" in LibTmux::X`](/en/perl/latest/reference/libtmux-x-codec/). Captured targets follow [`"set_environment"`](/en/perl/latest/reference/libtmux-server-set_environment/)'s generation checks.


```perl
    my $value = $server->get_environment(session => $session, name => 'BUILD');
```

## Methods

## Parameters

- `args`

## tmux command

The tmux commands behind `get_environment`.

- [`show-environment`](/en/tmux/latest/manual/show-environment/)

## tmux C API

The C declarations in tmux that implement these commands.

- [`cmd_show_environment_entry`](/en/tmux/latest/reference/c-variable-cmd_show_environment_entry/) (attribute)
- [`cmd_show_environment_exec`](/en/tmux/latest/reference/c-function-cmd-show-environment-c-cmd_show_environment_exec/) (function)

## In other ports

Read one variable from the server's environment

| Language | Equivalent |
| --- | --- |
| Python | no single-variable read; the whole table is returned |
| Haskell | No public Haskell equivalent is implemented; the current modules expose scalar values and version parsing. |
| TypeScript | [`server.Server.getEnvironment`](/en/ts/latest/reference/server-server-getenvironment/) (method) |
| Rust | [`server.Server.environment`](/en/rs/latest/reference/server-server-environment/) (method) |
| Go | [`tmux.Server.GetEnvironment`](/en/go/latest/reference/tmux-server-getenvironment/) (method) |
| Java | no single-variable read; the whole table is returned |
| C# | no single-variable read; the whole table is returned |
| C++ | no single-variable read; the whole table is returned |
| Swift | no single-variable read; the whole table is returned |
| OCaml | No direct public OCaml equivalent is recorded for this operation. |

No equivalent is recorded in Ruby, Lua, PowerShell, Julia, Erlang, Elixir, Common Lisp, Clojure, Kotlin, Scala or F#.

Read one variable from a session's environment

| Language | Equivalent |
| --- | --- |
| Python | no single-variable read; the whole table is returned |
| Haskell | No public Haskell equivalent is implemented; the current modules expose scalar values and version parsing. |
| TypeScript | [`session.Session.getEnvironment`](/en/ts/latest/reference/session-session-getenvironment/) (method) |
| Rust | [`session.Session.environment`](/en/rs/latest/reference/session-session-environment/) (method) |
| Go | [`tmux.Session.GetEnvironment`](/en/go/latest/reference/tmux-session-getenvironment/) (method) |
| Java | no single-variable read; the whole table is returned |
| C# | no single-variable read; the whole table is returned |
| C++ | no single-variable read; the whole table is returned |
| Swift | no single-variable read; the whole table is returned |
| OCaml | No direct public OCaml equivalent is recorded for this operation. |

No equivalent is recorded in Ruby, Lua, PowerShell, Julia, Erlang, Elixir, Common Lisp, Clojure, Kotlin, Scala or F#.
