#!/usr/bin/perl -w use strict; my ($desc, $data, $ref); while (){ if (/^Description:$/){ $ref = \$desc; next; }elsif (/^Data:$/){ $ref = \$data; next; } $$ref .= $_; } print "Desc:\n$desc\n---\nData:\n$data\n"; __DATA__ Description: yada_d1 yada_d1 yada_d1 yada_d1 Data: yada_d2 yada_d2 yada_d2 yada_d2