I
IanW
Hi
I have some strings like this (the print_r output from PHP):
my $str = "Array
(
[SY] => 1
[DN] => 1
[YO] => 1
[MK] => 1
[N] => 9
[HP] => 2
[LA] => 1
[NP] => 1
[SW] => 3
)";
I want to be able to parse that string into a Perl hash where the keys are
the letters inside the square brackets (eg: SY or N) and the values are the
numbers after the => (they will always be numeric).
I feel this should be achievable with a cunning one liner using the map
function along with some regexp output (/\[(\w+)\]\D+?(\d+)/) but I don't
know how to begin. ANy help appreciated.
Thanks
Ian
I have some strings like this (the print_r output from PHP):
my $str = "Array
(
[SY] => 1
[DN] => 1
[YO] => 1
[MK] => 1
[N] => 9
[HP] => 2
[LA] => 1
[NP] => 1
[SW] => 3
)";
I want to be able to parse that string into a Perl hash where the keys are
the letters inside the square brackets (eg: SY or N) and the values are the
numbers after the => (they will always be numeric).
I feel this should be achievable with a cunning one liner using the map
function along with some regexp output (/\[(\w+)\]\D+?(\d+)/) but I don't
know how to begin. ANy help appreciated.
Thanks
Ian