Usually when we use split, we provide a regex. Whatever the regex matches is "thrown away" and the pieces between these matches are returned. In this example we get back the two strings even including the spaces.


use strict;
use warnings;

use Data::Dumper qw(Dumper);

my $str = "abc 23 def";
my @pieces = split /\d+/, $str;

print Dumper \@pieces;