Which statement is "better", and why?

Discussion in 'Perl' started by Trebor A. Rude, Apr 24, 2004.

  1. 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
     
    Trebor A. Rude, Apr 24, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mr. SweatyFinger

    why why why why why

    Mr. SweatyFinger, Nov 28, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    989
    Mark Rae
    Dec 21, 2006
  2. Mr. SweatyFinger
    Replies:
    2
    Views:
    2,249
    Smokey Grindel
    Dec 2, 2006
  3. Replies:
    21
    Views:
    1,088
    Giannis Papadopoulos
    Aug 2, 2005
  4. Peter Bencsik
    Replies:
    2
    Views:
    880
  5. Trebor A. Rude

    Which statement is "better", and why?

    Trebor A. Rude, Apr 24, 2004, in forum: Perl Misc
    Replies:
    1
    Views:
    103
    Matija Papec
    Apr 24, 2004
Loading...

Share This Page