http://www.perlmonks.org?node_id=1208830


in reply to Store multiple lines

Have a look at the "awk" utility. Notice how they cleanly solve such problems. Then, look at "a2p."