$ perl -le' use Data::Dumper; my @y = map /(\d+)/, qw/ ab123cd ab456cd abcdefg ab789cd /; print Dumper \@y; ' $VAR1 = [ '123', '456', '789' ];