Login
You're viewing the techdon.dev public feed.
  • Sep 17, 2025, 1:19 PM

    @barubary

    ```
    ~$ perl -E 'use Data::Printer;
    sub schplitt ($pat, $str) {
    p $pat; p $str;
    };
    my @foo = schplitt(/:/, "user:pass");'

    Too few arguments for subroutine 'main::schplitt' (got 1; expected 2) at -e line 5.
    ```

    That's also certainly an... interesting error

    ```
    my @foo = schplitt(qr/:/, "user:pass");'

    : (modifiers: u)
    "user:pass"
    ```

    works of course as expected, is just rather more unsightly on the caller side than the builtin because of the qr prefix adding some noise.

    💬 1🔄 0⭐ 0

Replies

  • Sep 17, 2025, 1:31 PM

    @phl Yeah, schplitt(/:/, "user:pass") matches $_ (which is undefined, but you didn't enable warnings) against /:/ in list context, so the failing match returns an empty list, which is concatenated with "user:pass", giving a single-element argument list.

    💬 1🔄 0⭐ 0