in reply to You need more coffee when...

Your problem is that each match eats two "~" characters. So it'll skip every other section.

Try this instead:

$document =~ m!~\s*([^~]+?)\s*(?=~|$)!g;