#! perl -slw use strict; use Data::Dump qw[ pp ]; $Data::Dump::WIDTH = 50; my %hash = do{ local $/; } =~ m[(TAG\d=)\s+(.+?)(?=TAG|\Z)]gsm; pp \%hash; __DATA__ TAG1= data TAG2= more data TAG3= even more data that sometimes has = and runs on to more than one line TAG4= still more