On Oct 3, [EMAIL PROTECTED] said: >I'm having a difficult time understanding the map function.
You're having a hard time coping with the fact that $_ is an alias to the values in the list you're mapping over, not a copy. >@new_names = map { ($x = $_) =~ s/(jpg|gif)$/html/i; $x } @old_names; > >Is there a more elegant way to accomplish this? It just doesn't seem >elegant assigning $_ to $x, performing the substitution on $x, and then >returning $x. Sure: # no need to do two statements: # @new = @old; # ... for @new; # just do it all at once: s/(jpg|gif)$/html/i for @new_names = @old_names; -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ ** Look for "Regular Expressions in Perl" published by Manning, in 2002 ** <stu> what does y/// stand for? <tenderpuss> why, yansliterate of course. [ I'm looking for programming work. If you like my work, let me know. ] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]