http://qs1969.pair.com?node_id=569191


in reply to Parsing semi-erratic text

The data you submitted *does* have newlines.

while (<DATA>) { my ($key, $val) = /^\s*([^:]*?)\s*:\s*(.*?)\s*$/ or next; print("[$key:$val]\n"); }

and

while (<DATA>) { my ($key, $val) = split(/:/, $_, 2); next if not defined $val; s/^\s+//, s/\s+$// for $key, $val; print("[$key:$val]\n"); }

both do the trick.