$str='ABCD----[this] fgab [that] BFTE-- [other] AB CD EF---- [foo] +'; $hash{$1}=$2 while ($str=~m#\s*([\w ]+)[\s-]+\[([^\]]+)\]#g); print "$_=$hash{$_}\n" for keys %hash;
OUTPUT
fgab=that ABCD=this BFTE=other AB CD EF=foo
In reply to Re: converting an arbitrary string into a hash based on a pattern
by gopalr
in thread converting an arbitrary string into a hash based on a pattern
by punkish
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |