in reply to converting an arbitrary string into a hash based on a pattern
$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
|
|---|