in reply to Re: map and grep syntax question
in thread map and grep syntax question

the straight map loop is the most concise, i think, plus i need to work more with some of the added list ops.

i just want to extend my working knowledge of everything.

Replies are listed 'Best First'.
Re^3: map and grep syntax question
by revdiablo (Prior) on Dec 10, 2004 at 23:17 UTC
    the straight map loop is the most concise, i think

    The most concise solution is not always the best. Take a look at any Perl Golf contest for conclusive proof of this. :-) For example, here's another concise version:

    my $newLoop; push @{$newLoop},{PARTNAME=>$_,/$row->{title}/?(SELECTED=>1):()} for qw(Part1 Part2 Part3);

    But if I saw that in real code, I wouldn't be very happy.

    plus i need to work more with some of the added list ops. i just want to extend my working knowledge of everything.

    That's fine, but part of learning how to work with something is learning when not to use it. I can't say the map verion that Joost and I both came up with is the worst code I've seen, but it isn't particularly clear. So, learn how to use map, but also learn when to use something else.