use strict; use warnings; use 5.010; use Data::Dump qw(dump dd ddx); sub split_e { } split_e( // ); # Warning: Use of uninitialized value $_ in pattern match (m//) at pm_1.pl ... my @rv = split( //, '' ); # Warning: none my $str = '1-10,20'; my $pat = '(-)|(,)'; @rv = split( $pat, $str ); warn dump @rv; # (1, "-", undef, 10, undef , ",", 20) @rv = $str =~ m{$pat}g; warn dump @rv; # ("-", undef, undef, ",") while ( my $rv = $str =~ m{$pat}gc ) { for my $ix ( 0 .. 99 ) { if ( defined $-[$ix] ) { say sprintf '$ix= %d (%d,%d)<%s>', $ix, $-[$ix], $+[$ix], substr $str, $-[$ix], $+[$ix] - $-[$ix]; } } } say "Strawberry Perl $^V"; say $^O; __DATA__ output: $ix= 0 (1,2)<-> $ix= 1 (1,2)<-> $ix= 0 (4,5)<,> $ix= 2 (4,5)<,> Strawberry Perl v5.30.1 MSWin32