in reply to Surprised by join

I don't know what your rules are to have a ':' or a '' but what about a nice map statement?
$result = join /""/, (map {$_, $_ ? '' : ':'} @list);

pelagic

Replies are listed 'Best First'.
Re^2: Surprised by join
by EdwardG (Vicar) on Jun 08, 2004 at 13:43 UTC

    Yes indeed, map also does the trick, I'm just surprised that join doesn't, not without help anyway.

     

      join does not set $_ to each element obviously. And why is that so? Ask Larry!

      pelagic

        I will ask next time I meet him :)

        As I speculated above, it might not make sense to set $_ to each element since each step of the join must work on a pair of elements.