in reply to better way to convert a string into an array and an hash
My guess is:
Update: that's wrong of course. Here's the corrected one:
Sorry.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;
|
|---|