in reply to Accumulating data in a hash using map{split()}

use strict; use warnings; my $str = "name:val with a :"; my %hash; $hash{$_->[0]} = $_->[1] for [split /:/, $str, 2]; print map {"$_:$hash{$_}\n"} keys %hash;

Prints:

name:val with a :

but I'd not recommend it for production work. The two line variant is a lot less magical.

Note the third parameter to the split though.


DWIM is Perl's answer to Gödel