my @interesting = (); while() { chomp; push @interesting, $1 if m/^(?:attribute|value): (.*)$/; } my %attributes = @interesting; # magic