in reply to split versus =~

Like this?

#!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11148100 use warnings; for ( glob join '-', ('{-,}42') x 3 ) { my ($X, $Y, $Z) = /(-?\d+)-(-?\d+)-(-?\d+)/; printf "%11s => %3s %3s %3s\n", $_, $X, $Y, $Z; }

Outputs:

-42--42--42 => -42 -42 -42 -42--42-42 => -42 -42 42 -42-42--42 => -42 42 -42 -42-42-42 => -42 42 42 42--42--42 => 42 -42 -42 42--42-42 => 42 -42 42 42-42--42 => 42 42 -42 42-42-42 => 42 42 42

Replies are listed 'Best First'.
Re^2: split versus =~
by parv (Parson) on Nov 10, 2022 at 22:01 UTC
    for ( glob join '-', ('{-,}42') x 3 )

    I like that glob ... to generate a list (as I have not personally seen it used much outside of collecting file paths).