in reply to map it back jack

Here's a way to do it without using for or map:
$myhash{$v}=$_ while defined ($v=$_=pop@elements and y/_/ /);

Replies are listed 'Best First'.
Re: Re: map it back jack
by chipmunk (Parson) on Dec 16, 2000 at 22:15 UTC
    Watch out if @elements actually contains an undef value... :)
Re: Re: map it back jack
by johannz (Hermit) on Dec 16, 2000 at 04:47 UTC

    This even more than the rest has the problem of modifying the @elements array. In this case, it empties it.

      Why is it a problem? The original question never asks that the array remained untouched, merely (implied) that "for[each]" should not be used. Why not remove each element as we put it in the hash? :) TMTOWTDI