---
name: "Perl::Critic::Policy::TooMuchCode::ProhibitDuplicateLiteral"
section: "3pm"
platform: "linux"
package: "libperl-critic-toomuchcode-perl"
version: "0.19-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/Perl::Critic::Policy::TooMuchCode::ProhibitDuplicateLiteral"
---

# Perl::Critic::Policy::TooMuchCode::ProhibitDuplicateLiteral(3pm)

Don't repeat yourself with identical literals

## NAME

TooMuchCode::ProhibitDuplicateLiteral - Don't repeat yourself with identical literals

## DESCRIPTION

This policy checks if there are string/number literals with identical value in the same piece of perl code. Usually that's a small signal of repeating and perhaps a small chance of refactoring.

## CONFIGURATION

Some strings/numbers may be allowed to have duplicates by listing them in the `"allowlist"` parameter in the configs:

```
    [TooMuchCode::ProhibitDuplicateLiteral]
    allowlist = 'present' "forty two" 42
```

The values is a space-separated list of numbers or quoted string.

The default values in the allowlist are: `"0 1"`. These two numbers are always part of allowlist and cannot be removed.

Please be aware that, a string literal and its numerical literal counterpart (`1` vs `"1"`) are considered to be the same. Adding `"42"` to the allowlist is the same as adding `42`.
