in reply to How to create a hash from string
#!/usr/bin/perl use warnings; use strict; use Data::Dumper; my $string = 'x:q,y:u,z:n'; my %hash = split /[:,]/, $string; print Dumper \%hash; $string = '[x:q,y:u,z:n]'; %hash = split /[:,]/, substr $string, 1, -1; print Dumper \%hash;
|
|---|