---
title: "switch (ref $@) { OverflowError => warn 'Dam needs to be drained'; Do… — Larry Wall Quote #129 | QuotesBy.net"
description: "switch (ref $@) { OverflowError => warn 'Dam needs to be drained'; DomainError => warn 'King needs to be trained'; NuclearWarError => die; } — a quote by Larry Wall."
image: "https://quotesby.net/wp-content/themes/quotesby-editorial/assets/og-default.png"
---

> # switch (ref $@) { OverflowError =&gt; warn 'Dam needs to be drained'; DomainError =&gt; warn 'King needs to be trained'; NuclearWarError =&gt; die; }

[Larry Wall](https://quotesby.net/Larry-Wall)\#129

[Programming](https://quotesby.net/Larry-Wall/programming/)[Software](https://quotesby.net/Larry-Wall/software/)[Coding](https://quotesby.net/Larry-Wall/coding/)

[WhatsApp (opens in a new tab)](https://wa.me/?text=%E2%80%9Cswitch%20%28ref%20%24%40%29%20%7B%20OverflowError%20%3D%3E%20warn%20%27Dam%20needs%20to%20be%20drained%27%3B%20DomainError%20%3D%3E%20warn%20%27King%20needs%20to%20be%20trained%27%3B%20NuclearWarError%20%3D%3E%20die%3B%20%7D%E2%80%9D%20%E2%80%94%20Larry%20Wall%20https%3A%2F%2Fquotesby.net%2FLarry-Wall%2F129%2F)[X (opens in a new tab)](https://twitter.com/intent/tweet?text=%E2%80%9Cswitch%20%28ref%20%24%40%29%20%7B%20OverflowError%20%3D%3E%20warn%20%27Dam%20needs%20to%20be%20drained%27%3B%20DomainError%20%3D%3E%20warn%20%27King%20needs%20to%20be%20trained%27%3B%20NuclearWarError%20%3D%3E%20die%3B%20%7D%E2%80%9D%20%E2%80%94%20Larry%20Wall&url=https%3A%2F%2Fquotesby.net%2FLarry-Wall%2F129%2F)[Facebook (opens in a new tab)](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fquotesby.net%2FLarry-Wall%2F129%2F)

## About this quote

What does it mean?A code snippet shows handling different error types with warnings or termination.In plain termsThe program catches specific errors and either warns or aborts.What can you take from it?Map each error to an appropriate response.

### Where it applies

- in exception handling
- while debugging

### Putting it to work

- use selective catches
- log meaningful messages

### Questions to consider

- How does granular error handling improve software stability?

### Another view

The example uses humor (e.g., NuclearWarError) that may distract from the point.

## More from Larry Wall

1. > This has been planned for some time. I guess we'll just have to find someone with an exceptionally round tuit.

[Permalink to quote \#128](https://quotesby.net/Larry-Wall/128/ "Permalink to quote 128")
2. > I surely do hope that's a syntax error.

[Permalink to quote \#130](https://quotesby.net/Larry-Wall/130/ "Permalink to quote 130")
3. > I wasn't recommending that we make the links for them, only provide them with the tools to do so if they want to take the gamble (or the gambol).

[Permalink to quote \#127](https://quotesby.net/Larry-Wall/127/ "Permalink to quote 127")

## Related quotes

1. > A programming language is for thinking of programs, not for expressing programs you've already thought of.

[Paul Graham](https://quotesby.net/Paul-Graham)[Paul Graham quote \#10](https://quotesby.net/Paul-Graham/10/ "Permalink to quote 10")
2. > My programming language was solder.

[Terry Pratchett](https://quotesby.net/Terry-Pratchett)[Terry Pratchett quote \#2](https://quotesby.net/Terry-Pratchett/2/ "Permalink to quote 2")
3. > That's the thing about people who think they hate computers ... What they really hate are lousy programmers.

[Larry Niven](https://quotesby.net/Larry-Niven)[Larry Niven quote \#2](https://quotesby.net/Larry-Niven/2/ "Permalink to quote 2")

```json
{
    "@context": "https://schema.org",
    "@type": "Quotation",
    "text": "switch (ref $@) { OverflowError => warn 'Dam needs to be drained'; DomainError => warn 'King needs to be trained'; NuclearWarError => die; }",
    "url": "https://quotesby.net/Larry-Wall/129/",
    "spokenByCharacter": {
        "@type": "Person",
        "name": "Larry Wall"
    }
}
{
    "@context": "https://schema.org",
    "@type": "BreadcrumbList",
    "itemListElement": [
        {
            "@type": "ListItem",
            "position": 1,
            "name": "Home",
            "item": "https://quotesby.net/"
        },
        {
            "@type": "ListItem",
            "position": 2,
            "name": "Authors",
            "item": "https://quotesby.net/authors/"
        },
        {
            "@type": "ListItem",
            "position": 3,
            "name": "Larry Wall",
            "item": "https://quotesby.net/Larry-Wall"
        },
        {
            "@type": "ListItem",
            "position": 4,
            "name": "Quote #129",
            "item": "https://quotesby.net/Larry-Wall/129/"
        }
    ]
}
```
