Which statement is "better", and why?

From: Trebor A. Rude (treborrude_at_SPAMBGONE.comcast.net)
Date: 04/24/04


Date: Sat, 24 Apr 2004 18:35:00 GMT

I'm new to Perl (although I have about 7 years of C++ experience), and I was
just wondering which of these two equivalent statements the group thinks is
"better", and why:

push @command, map {exists $options{$_} ? ($options{$_}, $comments{$_}) :
()} keys %comments;

push @command, map {($options{$_}, $comments{$_})} grep exists $options{$_},
keys %comments;

What I'm doing: I have a hash (%comments) of comments from an ogg file and I
want to construct a command to pass to system() that will set the same tags
in an mp3 file (using the "id3v2" command-line program). The ogg will
typically have more tags in it than id3v2 can handle, so I need to select
just those comments that have equivalents in id3v2 tags (I've set them up
in the %options hash, with the ogg tag as the key and command-line switch
for the id3v2 program as the value). Both statements above do just that,
but I was wondering what the advantages and disadvantages of each are.

Trebor



Relevant Pages

  • Which statement is "better", and why?
    ... just wondering which of these two equivalent statements the group thinks is ... want to construct a command to pass to systemthat will set the same tags ... in an mp3 file (using the "id3v2" command-line program). ...
    (comp.lang.perl.misc)
  • [ANN] ruby-mp3info 0.5
    ... id3v2 tags. ... puts mp3.bitrate ... * id3v2 writing and removing support added. ... * FIXED bug on calculating id3v2 frame size ...
    (comp.lang.ruby)
  • Re: My Music Media Library - Artist Info & MP3 tags
    ... > that MCE will use v3.1 tags. ... or id3v1 as id3v2. ...
    (microsoft.public.windows.mediacenter)