Try this instead:
$document =~ m!~\s*([^~]+?)\s*(?=~|$)!g; [download]
In reply to Re: You need more coffee when... by bart in thread You need more coffee when... by Anonymous Monk