T
Trebor A. Rude
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
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