Commits

Shlomi Fish committed cba17d4

Convert a foreach/push loop to a map.

Comments (0)

Files changed (1)

modules/App-XML-DocBook-Docmake/lib/App/XML/DocBook/Docmake.pm

     my $output_file = $args->{output};
     my $template = $args->{template};
     
-    my @cmd;
-    foreach my $arg (@$template)
-    {
-        # If it's a string
-        if (ref($arg) eq "")
+    return
+    [
+        map
         {
-            push @cmd, $arg;
-        }
-        elsif ($arg->is_output())
-        {
-            push @cmd, $output_file;
-        }
-        elsif ($arg->is_input())
-        {
-            push @cmd, $input_file;
-        }
-        else
-        {
-            die "Unknown Argument in Command Template.";
-        }
-    }
-    return \@cmd;
+              (ref($_) eq '') ? $_
+            : $_->is_output() ? $output_file
+            : $_->is_input() ? $input_file
+            # Not supposed to happen
+            : do { die "Unknown Argument in Command Template."; }
+        } @$template
+    ];
 }
 
 sub _run_input_output_cmd