# LHS = Left-hand side # RHS = Right-hand side my $s = 'a,b=c,e=#f'; my %h = map { $_ .= "=fn($_)" unless /=/; # add a RHS s/#(\w+)/fn($1)/; # change the RHS '#' notation to the 'fn' notation split( /=/, $_, 2 ); # return the LHS=>RHS mapping (delim'd by a '=') } split /,/, $s; # split on commas to get the strings for the pairs