in reply to map a list

I'm not entirely sure if I understand your Problem. It is hard to tell when you are talking in terms of text replacement and when you mean actual Perl code. I believe that dragonchild has throroughly misunderstood the problem for the same reason.

Here is one way to do what I think you want to do:

@result = map { my ( $x, $y) = split /=#?/; /=#/ ? ( $x, fn( $y)) : /=/ ? ( $x, $y) : ( $x, fn( $x)); } split /,/, $string;
See how the code makes the map block a comfortable place, with named lexicals for the parts we work with. The nested ?: can then be written strightforward.

I think an approach more along the lines of dragonchild's (though he solved different problem) would be more readable and maintainable.

Anno

Update: Corrected misattribution to imp

Replies are listed 'Best First'.
Re^2: map a list
by evil_otto (Novice) on Mar 12, 2007 at 22:51 UTC
    Perhaps it was a bit unclear, in that I didn't specify that "fn()" is a perl sub defined elsewhere. Otherwise there is pretty much nothing to do with any text substitution - I just figured that much was clear from the working reduced case (and the non-working full case).