use strict; use warnings; use 5.010; my $th = 'hello-10-world-20'; my %things = split /-/, $th; while ( my($key, $val) = each %things ) { say "$key => $val"; } --output:-- hello => 10 world => 20