#!/usr/bin/perl use Data::Dumper; my $arg = shift; my %actualhash = eval $arg; print Dumper \%actualhash; #old bad way my %badhash = ('r,2,g,2,w,1'); #if you don't think too hard, this looks correct. print "\n%badhash:\n"; print Dumper \%badhash; print $@; my %hash = ('r',2,'g',2,'w',1); print "\n%hash:\n"; print Dumper \%hash; #print $@; unclutter output for posting to perlmonks--it just repeats the first error, of course my @array = qw/r 2 g 2 w 1/; my %newhash = @array; print "\npassing through qw:\n"; print Dumper \%newhash; #print $@; #### rasto@frodo:~/cheat$ ./test.pl 'r,2,g,2,w,1,q,1' $VAR1 = {}; %badhash: $VAR1 = { 'r,2,g,2,w,1' => undef }; Can't find string terminator "," anywhere before EOF at (eval 1) line 1. %hash: $VAR1 = { 'w' => 1, 'r' => 2, 'g' => 2 }; passing through qw: $VAR1 = { 'w' => '1', 'r' => '2', 'g' => '2' }; #### $VAR1 = { 'r,2,g,2,w,1' => undef };