in reply to map question

You're on the right lines, map is the right way to go. Rather than directly giving you the answer, I'd like to ask you to show us the code you tried so we can gain more insight into what you find confusing about map's documentation.

Update: Others have already answered your question, but it might be useful to see how and why you tried to use map to better understand how novices approach it. Also, it shows this isn't a "do my homework for me" question.

Replies are listed 'Best First'.
Re: Re: map question
by hotshot (Prior) on Mar 19, 2002 at 17:09 UTC
    I already started writing what I'v done and the answers stopped me in the middle, but here goes my old and wrong code:
    my $str = 'test number X'; my @numbers = (2, 3, 4); @newArray = map { ($_ = $str) =~ s/X/$_/ } @numbers;
    But I must add that I realized that wouldn't work even before I tried testing it, coz $_ in the regexp is no longer the one I expected.

    Thanks.

    Hotshot