#!/usr/bin/perl # http://perlmonks.org/?node_id=1207789 use strict; use warnings; use Data::Dumper; my $big_string = 'special:1001:area_code:617|special:1001:zip_code:02205|special:1001:dow:0|special:1001:tod:14'; my %hash = map +(split /:/)[-2, -1], split /\|/, $big_string; print Dumper \%hash;