in reply to better way to convert a string into an array and an hash

My guess is:

my $string = "1:1,2:1,3:2,500:2,505:1"; my %hash = $string=~/([-.\w]*):([-.\w]*),/g; my @array = $string=~/([-.\w]*):/g; use Data::Dumper; print Dumper \@array, \%hash;

Update: that's wrong of course. Here's the corrected one:

my $string = "1:1,2:1,3:2,500:2,505:1"; my %hash = $string=~/([-.\w]*):([-.\w]*)/g; @array = $string=~/([-.\w]*):/g; use Data::Dumper; print Dumper \@array, \%hash;
Sorry.